-
Notifications
You must be signed in to change notification settings - Fork 4
161 lines (135 loc) · 5.1 KB
/
check_terraform.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Check Terraform infrastructure
on:
pull_request:
workflow_dispatch:
inputs:
subscription:
description: 'Subscription'
type: choice
required: true
options:
- 's940'
- 's941'
default: 's941'
terraformapply:
description: 'Terraform apply'
type: boolean
required: true
default: false
# secrets:
# AZURE_CLIENT_ID:
# description: The client ID of the Azure AD service principal to use for authenticating to Azure.
# required: true
# AZURE_SUBSCRIPTION_ID:
# description: The ID of the Azure subscription to create the resources in.
# required: true
# AZURE_TENANT_ID:
# description: The ID of the Azure tenant to create the resources in.
# required: true
jobs:
terrform-s941:
name: Check infrastructure consistency
runs-on: ubuntu-latest
environment: s941
strategy:
matrix:
ENVIROMENT: [dev, playground]
env:
# ENVIROMENT: dev #variable passed to scipt
SUBSCRIPTION: s941 #variable passed to scipt
terraform_version: ~1.3.0
ARM_USE_OIDC: true
ARM_USE_AZUREAD: true
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
storage_account_name: ${{ inputs.subscription }}radixinfra
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4 #Clone Repo
- name: 'Az login'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Get GitHub Public IP
id: github_public_ip
run: echo "ipv4=$(curl 'https://ifconfig.me/ip')" >> $GITHUB_OUTPUT
- name: Add GitHub IP to StorageAccount
run: |
az storage account network-rule add \
--resource-group "${{ env.SUBSCRIPTION}}-tfstate" \
--account-name "${{ env.SUBSCRIPTION}}radixinfra" \
--ip-address ${{ steps.github_public_ip.outputs.ipv4 }} >/dev/null
- name: Lets sleep for 30 seconds for FW rule to complete
run: sleep 30s
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.terraform_version }}
- name: Check terrorm in ${{ matrix.ENVIROMENT}}
working-directory: terraform/subscriptions/scripts
run: ENVIROMENT=${{ matrix.ENVIROMENT}} ./terraform.sh
- name: Revoke GitHub IP on StorageAccount
run: |
az storage account network-rule remove \
--resource-group "${{ env.SUBSCRIPTION}}-tfstate" \
--account-name "${{ env.SUBSCRIPTION}}radixinfra" \
--ip-address ${{ steps.github_public_ip.outputs.ipv4 }} >/dev/null
terrform-s940:
name: Check infrastructure consistency
runs-on: ubuntu-latest
environment: s940
strategy:
matrix:
ENVIROMENT: [prod, c2]
env:
# ENVIROMENT: dev #variable passed to scipt
SUBSCRIPTION: s940 #variable passed to scipt
terraform_version: ~1.3.0
ARM_USE_OIDC: true
ARM_USE_AZUREAD: true
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
storage_account_name: ${{ inputs.subscription }}radixinfra
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4 #Clone Repo
- name: 'Az login'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Get GitHub Public IP
id: github_public_ip
run: echo "ipv4=$(curl 'https://ifconfig.me/ip')" >> $GITHUB_OUTPUT
- name: Add GitHub IP to StorageAccount
run: |
az storage account network-rule add \
--resource-group "${{ env.SUBSCRIPTION}}-tfstate" \
--account-name "${{ env.SUBSCRIPTION}}radixinfra" \
--ip-address ${{ steps.github_public_ip.outputs.ipv4 }} >/dev/null
- name: Lets sleep for 30 seconds for FW rule to complete
run: sleep 30s
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.terraform_version }}
- name: Check terrorm in ${{ matrix.ENVIROMENT}}
working-directory: terraform/subscriptions/scripts
run: ENVIROMENT=${{ matrix.ENVIROMENT}} ./terraform.sh
- name: Revoke GitHub IP on StorageAccount
run: |
az storage account network-rule remove \
--resource-group "${{ env.SUBSCRIPTION}}-tfstate" \
--account-name "${{ env.SUBSCRIPTION}}radixinfra" \
--ip-address ${{ steps.github_public_ip.outputs.ipv4 }} >/dev/null