Skip to content

Commit 7a11372

Browse files
jaredfholgatedonovm4matt-FFFFFF
authored
Release/azurerm v4 support (#84)
* support for azureRM 4.x * avm checks * Create .e2eignore * Create .e2eignore * repo governance, linting, e2eignore * Complete v4 support * Remove ignore * Fix azurerm version in test * Update SUPPORT.md Co-authored-by: Matt White <16320656+matt-FFFFFF@users.noreply.github.com> --------- Co-authored-by: donovm4 <mccoy.donov@gmail.com> Co-authored-by: Donovan McCoy <144926888+donovm4@users.noreply.github.com> Co-authored-by: Matt White <16320656+matt-FFFFFF@users.noreply.github.com>
1 parent a02df07 commit 7a11372

27 files changed

Lines changed: 301 additions & 322 deletions

.github/workflows/e2e.yml

Lines changed: 28 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,29 @@
11
---
2-
name: e2e test
3-
4-
on:
5-
pull_request:
6-
types: ['opened', 'reopened', 'synchronize']
7-
merge_group:
8-
workflow_dispatch:
9-
10-
permissions:
11-
contents: read
12-
id-token: write
13-
14-
jobs:
15-
getexamples:
16-
if: github.event.repository.name != 'terraform-azurerm-avm-template'
17-
runs-on: ubuntu-latest
18-
outputs:
19-
examples: ${{ steps.getexamples.outputs.examples }}
20-
steps:
21-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 #v4.2.1
22-
- name: get examples
23-
id: getexamples
24-
uses: Azure/terraform-azurerm-avm-template/.github/actions/e2e-getexamples@main
25-
with:
26-
github-token: ${{ secrets.GITHUB_TOKEN }}
27-
28-
testexamples:
29-
if: github.event.repository.name != 'terraform-azurerm-avm-template'
30-
runs-on: [ self-hosted, 1ES.Pool=ff314ac9fce031b9e7f5dde283f515666e148ae7 ]
31-
needs: getexamples
32-
environment: test
33-
env:
34-
TF_IN_AUTOMATION: 1
35-
TF_VAR_enable_telemetry: false
36-
strategy:
37-
matrix:
38-
example: ${{ fromJson(needs.getexamples.outputs.examples) }}
39-
fail-fast: false
40-
steps:
41-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 #v4.2.1
42-
43-
- name: Test example
44-
shell: bash
45-
env:
46-
SECRETS_CONTEXT: ${{ toJson(secrets) }}
47-
VARS_CONTEXT: ${{ toJson(vars) }}
48-
run: |
49-
set -e
50-
MAX_RETRIES=10
51-
RETRY_COUNT=0
52-
until [ $RETRY_COUNT -ge $MAX_RETRIES ]
53-
do
54-
az login --identity --username $MSI_ID > /dev/null && break
55-
RETRY_COUNT=$[$RETRY_COUNT+1]
56-
sleep 10
57-
done
58-
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
59-
echo "Failed to login after $MAX_RETRIES attempts."
60-
exit 1
61-
fi
62-
63-
declare -A secrets
64-
eval "$(echo $SECRETS_CONTEXT | jq -r 'to_entries[] | @sh "secrets[\(.key|tostring)]=\(.value|tostring)"')"
65-
66-
declare -A variables
67-
eval "$(echo $VARS_CONTEXT | jq -r 'to_entries[] | @sh "variables[\(.key|tostring)]=\(.value|tostring)"')"
68-
69-
for key in "${!secrets[@]}"; do
70-
if [[ $key = \TF_VAR_* ]]; then
71-
lowerKey=$(echo "$key" | tr '[:upper:]' '[:lower:]')
72-
finalKey=${lowerKey/tf_var_/TF_VAR_}
73-
export "$finalKey"="${secrets[$key]}"
74-
fi
75-
done
76-
77-
for key in "${!variables[@]}"; do
78-
if [[ $key = \TF_VAR_* ]]; then
79-
lowerKey=$(echo "$key" | tr '[:upper:]' '[:lower:]')
80-
finalKey=${lowerKey/tf_var_/TF_VAR_}
81-
export "$finalKey"="${variables[$key]}"
82-
fi
83-
done
84-
85-
echo -e "Custom environment variables:\n$(env | grep TF_VAR_ | grep -v ' "TF_VAR_')"
86-
87-
export ARM_SUBSCRIPTION_ID=$(az login --identity --username $MSI_ID | jq -r '.[0] | .id')
88-
export ARM_TENANT_ID=$(az login --identity --username $MSI_ID | jq -r '.[0] | .tenantId')
89-
export ARM_CLIENT_ID=$(az identity list | jq -r --arg MSI_ID "$MSI_ID" '.[] | select(.principalId == $MSI_ID) | .clientId')
90-
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/src -w /src --network=host -e TF_IN_AUTOMATION -e TF_VAR_enable_telemetry -e AVM_MOD_PATH=/src -e AVM_EXAMPLE=${{ matrix.example }} -e MSI_ID -e ARM_SUBSCRIPTION_ID -e ARM_TENANT_ID -e ARM_CLIENT_ID -e ARM_USE_MSI=true --env-file <(env | grep TF_VAR_ | grep -v ' "TF_VAR_') mcr.microsoft.com/azterraform:latest make test-example
91-
92-
# This job is only run when all the previous jobs are successful.
93-
# We can use it for PR validation to ensure all examples have completed.
94-
testexamplescomplete:
95-
if: github.event.repository.name != 'terraform-azurerm-avm-template'
96-
runs-on: ubuntu-latest
97-
needs: testexamples
98-
steps:
99-
- run: echo "All tests passed"
2+
name: test examples
3+
on:
4+
pull_request:
5+
types: ['opened', 'reopened', 'synchronize']
6+
merge_group:
7+
workflow_dispatch:
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checking for Fork
14+
shell: pwsh
15+
run: |
16+
$isFork = "${{ github.event.pull_request.head.repo.fork }}"
17+
if($isFork -eq "true") {
18+
echo "### WARNING: This workflow is disabled for forked repositories. Please follow the [release branch process](https://azure.github.io/Azure-Verified-Modules/contributing/terraform/terraform-contribution-flow/#5-create-a-pull-request-to-the-upstream-repository) if end to end tests are required." >> $env:GITHUB_STEP_SUMMARY
19+
}
20+
21+
run-e2e-tests:
22+
if: github.event.pull_request.head.repo.fork == false
23+
uses: Azure/terraform-azurerm-avm-template/.github/workflows/test-examples-template.yml@main
24+
name: end to end
25+
secrets: inherit
26+
permissions:
27+
id-token: write
28+
contents: read
29+

.github/workflows/linting.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: checkout repository
24-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 #v4.2.1
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
2525

2626
- name: check docs
2727
uses: Azure/terraform-azurerm-avm-template/.github/actions/docs-check@main
@@ -32,7 +32,7 @@ jobs:
3232
runs-on: ubuntu-latest
3333
steps:
3434
- name: checkout repository
35-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 #v4.2.1
35+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
3636

3737
- name: lint terraform
3838
uses: Azure/terraform-azurerm-avm-template/.github/actions/linting@main
@@ -45,7 +45,7 @@ jobs:
4545
runs-on: ubuntu-latest
4646
steps:
4747
- name: checkout repository
48-
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 #v4.2.1
48+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
4949

5050
- name: avmfix
5151
uses: Azure/terraform-azurerm-avm-template/.github/actions/avmfix@main
@@ -54,4 +54,4 @@ jobs:
5454
needs: [docs, terraform, avmfix]
5555
runs-on: ubuntu-latest
5656
steps:
57-
- run: echo "All linting checks passed"
57+
- run: echo "All linting checks passed"

.github/workflows/version-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
if: github.event.repository.name != 'terraform-azurerm-avm-template'
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 #v4.2.1
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
2020
- name: Check version
2121
uses: Azure/terraform-azurerm-avm-template/.github/actions/version-check@main
2222
with:
23-
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
github_token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The following requirements are needed by this module:
99

1010
- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (>= 1.5.2)
1111

12-
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.71)
12+
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (>= 3.71, < 5.0.0)
1313

1414
- <a name="requirement_modtm"></a> [modtm](#requirement\_modtm) (~> 0.3)
1515

avm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fi
2727
# Check if we are running in a container
2828
# If we are then just run make directly
2929
if [ -z "$AVM_IN_CONTAINER" ]; then
30-
$CONTAINER_RUNTIME run --pull always --user "$(id -u):$(id -g)" --rm $AZURE_VOLUME -v /etc/passwd:/etc/passwd -v /etc/group:/etc/group -v "$(pwd)":/src -w /src -e GITHUB_REPOSITORY -e ARM_SUBSCRIPTION_ID -e GITHUB_REPOSITORY_OWNER mcr.microsoft.com/azterraform make "$1"
30+
$CONTAINER_RUNTIME run --pull always --user "$(id -u):$(id -g)" --rm $AZURE_VOLUME -v "$(pwd)":/src -w /src -e GITHUB_TOKEN -e GITHUB_REPOSITORY -e ARM_SUBSCRIPTION_ID -e GITHUB_REPOSITORY_OWNER mcr.microsoft.com/azterraform make "$1"
3131
else
3232
make "$1"
33-
fi
33+
fi

avm.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ IF "%~1"=="" (
1818
)
1919

2020
REM Run the make target with CONTAINER_RUNTIME
21-
%CONTAINER_RUNTIME% run --pull always --rm -v "%cd%":/src -w /src --user "1000:1000" -e ARM_SUBSCRIPTION_ID -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER mcr.microsoft.com/azterraform make %1
21+
%CONTAINER_RUNTIME% run --pull always --rm -v "%cd%":/src -w /src --user "1000:1000" -e GITHUB_TOKEN -e ARM_SUBSCRIPTION_ID -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER mcr.microsoft.com/azterraform make %1
2222

23-
ENDLOCAL
23+
ENDLOCAL

avm.tflint.override.hcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rule "provider_azurerm_version" {
2+
enabled = false
3+
}

avm.tflint_example.override.hcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rule "provider_azurerm_version" {
2+
enabled = false
3+
}

avm.tflint_module.hcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
plugin "terraform" {
22
enabled = true
3-
version = "0.5.0"
3+
version = "0.10.0"
44
source = "github.com/terraform-linters/tflint-ruleset-terraform"
55
}
66

77
plugin "avm" {
88
enabled = true
9-
version = "0.11.1"
9+
version = "0.11.5"
1010
source = "github.com/Azure/tflint-ruleset-avm"
1111
signing_key = <<-KEY
1212
-----BEGIN PGP PUBLIC KEY BLOCK-----
@@ -190,4 +190,4 @@ rule "tags" {
190190

191191
rule "provider_modtm_version" {
192192
enabled = false
193-
}
193+
}

examples/complete/.terraform-docs.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)