Skip to content

Commit 918daa7

Browse files
authored
Merge pull request #453 from sassoftware/staging
10.2.0 - March 19, 2025
2 parents 00d33fd + 8634508 commit 918daa7

32 files changed

+2371
-44
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ docs/
22
*.md
33
*.txt
44
terraform.tfstate*
5-
examples/
65
.terraform/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Default Plan Unit Tests
5+
on:
6+
push:
7+
branches: ['**'] # '*' will cause the workflow to run on all commits to all branches.
8+
9+
jobs:
10+
go-tests:
11+
name: Default Plan Unit Tests
12+
runs-on: ubuntu-latest
13+
environment: terraformSecrets
14+
steps:
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
- name: Build Docker Image
18+
run: docker build -t viya4-iac-azure:terratest -f Dockerfile.terratest .
19+
- name: Run Tests
20+
run: |
21+
docker run \
22+
-e TF_VAR_subscription_id=$TF_VAR_subscription_id \
23+
-e TF_VAR_tenant_id=$TF_VAR_tenant_id \
24+
-e TF_VAR_client_id=$TF_VAR_client_id \
25+
-e TF_VAR_client_secret=$TF_VAR_client_secret \
26+
-v $(pwd):/viya4-iac-azure \
27+
viya4-iac-azure:terratest -v
28+
env:
29+
# TF ENVIRONMENT
30+
TF_VAR_subscription_id: "${{ secrets.TF_VAR_SUBSCRIPTION_ID }}"
31+
TF_VAR_tenant_id: "${{ secrets.TF_VAR_TENANT_ID }}"
32+
TF_VAR_client_id: "${{ secrets.TF_VAR_CLIENT_ID }}"
33+
TF_VAR_client_secret: "${{ secrets.TF_VAR_CLIENT_SECRET }}"

.github/workflows/linter-analysis.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ jobs:
4646
path: ~/.tflint.d/plugins
4747
key: ubuntu-latest-tflint-${{ hashFiles('.tflint.hcl') }}
4848

49+
- name: Setup Terraform
50+
uses: hashicorp/setup-terraform@v3
51+
with:
52+
terraform_version: "^1.10.5"
53+
terraform_wrapper: false
54+
4955
- name: Setup TFLint
5056
uses: terraform-linters/setup-tflint@v3.0.0
5157
with:

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ terraform.tfvars
99
.terraform.lock.hcl
1010
.DS_Store
1111
sas_iac_buildinfo.yaml
12+
.idea
13+
.vscode
14+
test/bin
15+
test/pkg
16+
test/test_output

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
default_stages: [pre-commit]
3+
repos:
4+
- repo: https://github.com/gitleaks/gitleaks
5+
rev: v8.23.3
6+
hooks:
7+
- id: gitleaks
8+
9+
ci:
10+
autofix_prs: false
11+
autoupdate_commit_msg: "chore: auto-update of pre-commit hooks"

CONTRIBUTING.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
# How to Contribute
2-
We'd love to accept your patches and contributions to this project.
3-
We just ask that you follow our contribution guidelines when you do.
2+
This project is community-driven, and we'd love to accept your patches and contributions.
3+
We just ask that you follow our contribution guidelines when you do. Refer
4+
to the [Contributor Handbook](https://sassoftware.github.io/contributor-handbook.html)
5+
for guidance.
46

57
## Contributor License Agreement
68
Contributions to this project must be accompanied by a signed [Contributor Agreement](ContributorAgreement.txt).
7-
You (or your employer) retain the copyright to your contribution; this simply grants us permission to use and redistribute your contributions as part of the project.
9+
You (or your employer) retain the copyright to your contribution; this agreement simply grants
10+
us permission to use and redistribute your contributions as part of the project.
811

9-
## Code reviews
10-
All submissions to this project—including submissions from project members—require review.
11-
Our review process typically involves performing unit tests, development tests, integration tests, and security scans using internal SAS infrastructure.
12-
For this reason, we don’t often merge pull requests directly from GitHub.
12+
## Code Reviews
13+
All submissions to this project—including submissions from project members—require
14+
review. Our review process typically involves performing unit tests, development
15+
tests, integration tests, and security scans.
1316

14-
Instead, we work with submissions internally first, vetting them to ensure they meet our security and quality standards.
15-
We’ll do our best to work with contributors in public issues and pull requests; however, to ensure our code meets our internal compliance standards, we may need to incorporate your submission into a solution we push ourselves.
17+
## Pull Request Requirement
18+
All contributions (PRs) must be accompanied by passing unit and/or integration
19+
tests, following our [testing philosophy](./docs/user/TestingPhilosophy.md). If you are unfamiliar with this process,
20+
we are happy to help you navigate it by providing continuous collaboration within the pull request.
21+
All pull requests must also pass our linter analysis checks. Contributions might
22+
be subjected to security scans before they can be accepted.
1623

17-
This does not mean we don’t value or appreciate your contribution.
18-
We simply need to review your code internally before merging it.
19-
We work to ensure all contributors receive appropriate recognition for their contributions, at least by acknowledging them in our release notes.
24+
## Security Scans
25+
To ensure that all submissions meet our security and quality standards, we perform security
26+
scans using internal SAS infrastructure. Reporting of any Common Vulnerabilities and Exposures
27+
(CVEs) that are detected is not available in this project at this time.

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
ARG TERRAFORM_VERSION=1.9.6
2-
ARG AZURECLI_VERSION=2.64.0
1+
ARG TERRAFORM_VERSION=1.10.5
2+
ARG AZURECLI_VERSION=2.70.0
33

44
FROM hashicorp/terraform:$TERRAFORM_VERSION as terraform
55
FROM mcr.microsoft.com/azure-cli:$AZURECLI_VERSION
6-
ARG KUBECTL_VERSION=1.30.6
6+
ARG KUBECTL_VERSION=1.30.10
77

88
WORKDIR /viya4-iac-azure
99

1010
COPY --from=terraform /bin/terraform /bin/terraform
1111
COPY . .
1212

13-
RUN yum -y install git openssh jq which curl \
14-
&& yum clean all && rm -rf /var/cache/yum \
13+
RUN tdnf -y install git which \
14+
&& tdnf clean all && rm -rf /var/cache/tdnf \
1515
&& curl -sLO https://dl.k8s.io/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl \
1616
&& chmod 755 ./kubectl /viya4-iac-azure/docker-entrypoint.sh \
1717
&& mv ./kubectl /usr/local/bin/kubectl \

Dockerfile.terratest

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM golang:1.23
2+
3+
# Install terraform from apt repository and terratest_log_parser
4+
RUN \
5+
apt-get update \
6+
&& apt-get install -y jq lsb-release \
7+
&& wget -O - https://apt.releases.hashicorp.com/gpg \
8+
| gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg \
9+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" \
10+
| tee /etc/apt/sources.list.d/hashicorp.list \
11+
&& apt update \
12+
&& apt install terraform \
13+
&& ssh-keygen -f ~/.ssh/id_rsa -P "" \
14+
&& go install github.com/gruntwork-io/terratest/cmd/terratest_log_parser@latest
15+
16+
WORKDIR /viya4-iac-azure/test
17+
18+
# Copy the test directory so it can install the go modules
19+
# during the docker build rather than the docker run
20+
COPY ./test ./
21+
RUN go mod tidy
22+
23+
ENTRYPOINT ["/viya4-iac-azure/test/terratest_docker_entrypoint.sh"]

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# from .github/workflows/default_plan_unit_tests.yml
5+
6+
IMAGE := viya4-iac-azure:terratest
7+
8+
buildTests:
9+
ifeq ($(shell docker images -q $(IMAGE) 2> /dev/null),)
10+
docker build -t $(IMAGE) -f Dockerfile.terratest .
11+
endif
12+
13+
checkEnv:
14+
ifndef TF_VAR_subscription_id
15+
$(error TF_VAR_subscription_id is undefined)
16+
endif
17+
ifndef TF_VAR_tenant_id
18+
$(error TF_VAR_tenant_id is undefined)
19+
endif
20+
ifndef TF_VAR_client_id
21+
$(error TF_VAR_client_id is undefined)
22+
endif
23+
ifndef TF_VAR_client_secret
24+
$(error TF_VAR_client_secret is undefined)
25+
endif
26+
27+
28+
runTests: checkEnv buildTests
29+
docker run -it --rm \
30+
-e TF_VAR_subscription_id=$(TF_VAR_subscription_id) \
31+
-e TF_VAR_tenant_id=$(TF_VAR_tenant_id) \
32+
-e TF_VAR_client_id=$(TF_VAR_client_id) \
33+
-e TF_VAR_client_secret=$(TF_VAR_client_secret) \
34+
-v "$(PWD)":/viya4-iac-azure \
35+
$(IMAGE) -v
36+
37+
clean:
38+
docker image rm $(IMAGE)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ This project supports two options for running Terraform scripts:
5757
Access to an **Azure Subscription** and an [**Identity**](./docs/user/TerraformAzureAuthentication.md) with the *Contributor* role are required.
5858

5959
#### Terraform Requirements:
60-
- [Terraform](https://www.terraform.io/downloads.html) - v1.9.6
61-
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl) - v1.30.6
60+
- [Terraform](https://www.terraform.io/downloads.html) - v1.10.5
61+
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl) - v1.30.10
6262
- [jq](https://stedolan.github.io/jq/) - v1.6
63-
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure) - (optional - useful as an alternative to the Azure Portal) - v2.64.0
63+
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure) - (optional - useful as an alternative to the Azure Portal) - v2.70.0
6464

6565
#### Docker Requirements:
6666
- [Docker](https://docs.docker.com/get-docker/)

container-structure-test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ commandTests:
2121
- name: "terraform version"
2222
command: "terraform"
2323
args: ["--version"]
24-
expectedOutput: ["Terraform v1.9.6"]
24+
expectedOutput: ["Terraform v1.10.5"]
2525
- name: "python version"
2626
command: "python3"
2727
args: ["--version"]
@@ -32,11 +32,11 @@ commandTests:
3232
- -c
3333
- |
3434
az version -o tsv
35-
expectedOutput: ["2.64.0\t2.64.0\t1.1.0"]
35+
expectedOutput: ["2.70.0\t2.70.0\t1.1.0"]
3636
- name: "kubectl version"
3737
command: "kubectl"
3838
args: ["version", "--client"]
39-
expectedOutput: ["Client Version: v1.30.6"]
39+
expectedOutput: ["Client Version: v1.30.10"]
4040

4141
metadataTest:
4242
workdir: "/viya4-iac-azure"

docs/CONFIG-VARS.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,22 @@ The default values for the `subnets` variable are as follows:
127127
aks = {
128128
"prefixes": ["192.168.0.0/23"],
129129
"service_endpoints": ["Microsoft.Sql"],
130-
"private_endpoint_network_policies": "Disabled",
130+
"private_endpoint_network_policies": "Enabled",
131131
"private_link_service_network_policies_enabled": false,
132132
"service_delegations": {},
133133
}
134134
misc = {
135135
"prefixes": ["192.168.2.0/24"],
136136
"service_endpoints": ["Microsoft.Sql"],
137-
"private_endpoint_network_policies": "Disabled",
137+
"private_endpoint_network_policies": "Enabled",
138138
"private_link_service_network_policies_enabled": false,
139139
"service_delegations": {},
140140
}
141141
## If using ha storage then the following is also added
142142
netapp = {
143143
"prefixes": ["192.168.3.0/24"],
144144
"service_endpoints": [],
145-
"private_endpoint_network_policies": "Disabled",
145+
"private_endpoint_network_policies": "Enabled",
146146
"private_link_service_network_policies_enabled": false,
147147
"service_delegations": {
148148
netapp = {
@@ -211,6 +211,7 @@ Ubuntu 20.04 LTS is the operating system used on the Jump/NFS servers. Ubuntu cr
211211
| aks_cluster_private_dns_zone_id | Specifies private DNS zone resource ID for AKS private cluster to use | string | "" | For `cluster_api_mode=private` if `aks_cluster_private_dns_zone_id` is not specified then the value `System` is used else it is set to null. For details see [Configure a private DNS zone](https://learn.microsoft.com/en-us/azure/aks/private-clusters?tabs=azure-portal#configure-a-private-dns-zone) |
212212
| aks_cluster_sku_tier | The SKU Tier that should be used for this Kubernetes Cluster. Optimizes api server for cost vs availability | string | "Free" | Valid Values: "Free", "Standard" and "Premium" |
213213
| cluster_support_tier | Specifies the support plan which should be used for this Kubernetes Cluster. | string | "KubernetesOfficial" | Possible values are `KubernetesOfficial` and `AKSLongTermSupport`. To enable long term K8s support is a combination of setting `aks_cluster_sku_tier` to `Premium` tier and explicitly selecting the `cluster_support_tier` as `AKSLongTermSupport`. For details see [Long term Support](https://learn.microsoft.com/en-us/azure/aks/long-term-support) and for which K8s version has long term support see [AKS Kubernetes release calendar](https://learn.microsoft.com/en-us/azure/aks/supported-kubernetes-versions?tabs=azure-cli#aks-kubernetes-release-calendar).|
214+
| aks_cluster_run_command_enabled | Enable or disable the AKS Run Command feature | bool | false | The AKS Run Command feature in AKS allows you to remotely execute commands within a running container of your AKS cluster directly from the Azure CLI or Azure portal. To enable the Run Command feature for an AKS cluster where Run Command is disabled, navigate to the Run Command tab for your AKS Cluster in the Azure Portal and select the Enable button. |
214215

215216
## Node Pools
216217

@@ -368,7 +369,7 @@ Each server element, like `foo = {}`, can contain none, some, or all of the para
368369

369370
| Name | Description | Type | Default | Notes |
370371
| :--- | ---: | ---: | ---: | ---: |
371-
| sku_name| The SKU Name for the PostgreSQL Flexible Server | string | "GP_Standard_D4ds_v5" | The name pattern is the SKU, followed by the tier + family + cores (e.g. B_Standard_B1ms, GP_Standard_D2s_v3, MO_Standard_E4s_v3).|
372+
| sku_name| The SKU Name for the PostgreSQL Flexible Server | string | "GP_Standard_D4ds_v5" | The name pattern is the SKU, followed by the tier + family + cores (e.g. B_Standard_B1ms, GP_Standard_D2s_v5, MO_Standard_E4s_v5).|
372373
| storage_mb | The max storage allowed for the PostgreSQL Flexible Server | number | 131072 | Possible values are 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, and 33554432. |
373374
| backup_retention_days | Backup retention days for the PostgreSQL Flexible server | number | 7 | Supported values are between 7 and 35 days. |
374375
| geo_redundant_backup_enabled | Enable Geo-redundant or not for server backup | bool | false | Not supported for the basic tier. |

docs/user/TerratestDockerUsage.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Using the Terratest Docker Container
2+
3+
Use the Terratest Docker container to run the suite of Terratest Go tests. For more information on Terratest, follow the [Documentation](https://terratest.gruntwork.io/docs/) page. The Terratest Docker image is used by the [Github Workflow](../../.github/workflows/default_plan_unit_tests.yml) as a required check before merging changes.
4+
5+
## Prereqs
6+
7+
- Docker [installed on your workstation](../../README.md#docker).
8+
9+
## Preparation
10+
11+
### Docker image
12+
13+
Run the following command to create the `viya4-iac-azure-terratest` Docker image using the provided [Dockerfile.terratest](../../Dockerfile.terratest)
14+
15+
```bash
16+
docker build -t viya4-iac-azure-terratest -f Dockerfile.terratest .
17+
```
18+
19+
The Docker image `viya4-iac-azure-terratest` will contain Terraform and Go executables, as well as the required Go modules. The Docker entrypoint for the image is `go test`, and it accepts several optional command-line arguments. For more information about command-line arguments, see [Command-Line Arguments](#command-line-arguments).
20+
21+
### Docker Environment File for Azure Authentication
22+
23+
Follow either one of the authentication methods that are described in [Authenticating Terraform to access Azure](./TerraformAzureAuthentication.md), and create a file with the authentication variable values to use with container invocation. Store these values outside of this repository in a secure file, such as
24+
`$HOME/.azure_docker_creds.env`. Protect that file with Azure credentials so that only you have Read access to it. **NOTE**: Do not use quotation marks around the values in the file, and be sure to avoid any trailing blank spaces.
25+
26+
Now each time you invoke the container, specify the file with the [`--env-file`](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file) option to pass Azure credentials to the container.
27+
28+
### Docker Volume Mounts
29+
30+
Run the following command:
31+
`--volume="$(pwd)":/viya4-iac-azure`
32+
Note that the project must be mounted to the `/viya4-iac-azure` directory.
33+
34+
## Command-Line Arguments
35+
36+
The `terratest_docker_entrypoint.sh` script supports several command-line arguments to customize the test execution. Here are the available options:
37+
38+
* `-p, --package=PACKAGE`: The package to test. Default is './...'
39+
* `-r, --run=TEST`: The name of the test to run. Default is '.\*Plan.\*'.
40+
* `-v, --verbose`: Run the tests in verbose mode.
41+
* `-h, --help`: Display the help message.
42+
43+
## Running Terratest Commands
44+
45+
### Running the Default Tests
46+
47+
To run the default suite of unit tests (only `terraform plan`), run the following Docker command:
48+
49+
```bash
50+
# Run from the ./viya4-iac-azure directory
51+
docker run --rm \
52+
--env-file=$HOME/.azure_docker_creds.env \
53+
--volume "$(pwd)":/viya4-iac-azure \
54+
viya4-iac-azure-terratest
55+
```
56+
57+
### Running a Specific Go Test
58+
59+
To run a specific test, run the following Docker command with the `-r` option:
60+
61+
```bash
62+
# Run from the ./viya4-iac-azure directory
63+
docker run --rm \
64+
--env-file=$HOME/.azure_docker_creds.env \
65+
--volume "$(pwd)":/viya4-iac-azure \
66+
viya4-iac-azure-terratest \
67+
  -r="YourTest"
68+
```
69+
To run multiple tests, pass in a regex to the `-r` option - "TestName1|TestName2|TestName3"
70+
71+
### Running a Specific Go Package and Test
72+
73+
If you want to specify the Go package and test name, run the following Docker command with the following options:
74+
75+
```bash
76+
# Run from the ./viya4-iac-azure directory
77+
docker run --rm \
78+
--env-file=$HOME/.azure_docker_creds.env \
79+
--volume "$(pwd)":/viya4-iac-azure \
80+
viya4-iac-azure-terratest \
81+
  -r="YourTest" \
82+
  -p="YourPackage"
83+
```
84+
85+
### Running the Go Tests with verbose mode
86+
87+
If you want to run the tests in verbose mode, run the Docker command with the `-v` option:
88+
89+
```bash
90+
# Run from the ./viya4-iac-azure directory
91+
docker run --rm \
92+
--env-file=$HOME/.azure_docker_creds.env \
93+
--volume "$(pwd)":/viya4-iac-azure \
94+
viya4-iac-azure-terratest -v
95+
```
96+
97+
### Accessing test run logs
98+
99+
After you have started the Docker container, log files are created in the `./viya4-iac-azure/test/test_output` directory. These files enable you to view the test results in XML format, as well as test logs that are generated by the terrratest_log_parser.

0 commit comments

Comments
 (0)