-
Notifications
You must be signed in to change notification settings - Fork 75
686 lines (655 loc) · 28.8 KB
/
deploy_standard.yml
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
name: Deploy to Azure Spring Apps Standard with Petclinic
on: workflow_dispatch
permissions:
id-token: write
contents: read
env:
# === Deploy Firewall ===:
DEPLOY_FIREWALL_STANDARD: false
# === Destroy All ==
DESTROY_STANDARD: false
# === Baseline Parameters ====:
REGION: eastus
NAME_PREFIX: springlza
ENVIRONMENT: dev
# === Spring Apps Service ===:
SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
JUMP_BOX_USERNAME: ltzadmin
JUMP_BOX_PASSWORD: ${{ secrets.JUMP_BOX_PASSWORD }}
# Specify the Object ID for the "Azure Spring Apps Resource Provider" service principal in the customer's Azure AD Tenant
# Use this command to obtain:
# az ad sp show --id e8de9221-a19c-4c81-b814-fd37c6caf9d2 --query id --output tsv
SPRINGAPPS_SPN_OBJECT_ID: ${{ vars.SPRINGAPPS_SPN_OBJECT_ID }}
# === Pet Clinic Required Settings ===:
MYSQL_ADMIN_USERNAME: mySqlAdmin
MYSQL_ADMIN_PASSWORD: ${{ secrets.MYSQL_ADMIN_PASSWORD }}
# ==== Terraform Backend ===:
TFSTATE_RG: ${{ vars.TFSTATE_RG }}
STORAGEACCOUNTNAME: ${{ vars.STORAGEACCOUNTNAME }}
CONTAINERNAME: ${{ vars.CONTAINERNAME_STANDARD }}
# ==== Terraform Azure Login ===:
ARM_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
# ==== APPS ====:
API_GATEWAY: api-gateway
ADMIN_SERVER: admin-server
CUSTOMERS_SERVICE: customers-service
VETS_SERVICE: vets-service
VISITS_SERVICE: visits-service
# ==== JARS ====:
API_GATEWAY_JAR: spring-petclinic-api-gateway/target/api-gateway-3.0.1.jar
ADMIN_SERVER_JAR: spring-petclinic-admin-server/target/admin-server-3.0.1.jar
CUSTOMERS_SERVICE_JAR: spring-petclinic-customers-service/target/customers-service-3.0.1.jar
VETS_SERVICE_JAR: spring-petclinic-vets-service/target/vets-service-3.0.1.jar
VISITS_SERVICE_JAR: spring-petclinic-visits-service/target/visits-service-3.0.1.jar
jobs:
conditions:
runs-on: ubuntu-latest
outputs:
deploy_firewall: "${{ env.DEPLOY_FIREWALL_STANDARD }}"
destroy: "${{ env.DESTROY_STANDARD }}"
name_prefix: ${{ env.NAME_PREFIX}}
environment: ${{ env.ENVIRONMENT}}
region: ${{env.REGION}}
jumpbox_username: ${{ env.JUMP_BOX_USERNAME}}
mysql_admin_name: ${{env.MYSQL_ADMIN_USERNAME}}
steps:
- name: Deploy Firewall Override
if: ${{vars.DEPLOY_FIREWALL_STANDARD != 0 }}
run: echo "DEPLOY_FIREWALL_STANDARD=${{ vars.DEPLOY_FIREWALL_STANDARD }}" >> $GITHUB_ENV
- name: Destroy Override DESTROY_STANDARD
if: ${{vars.DESTROY_STANDARD != 0 }}
run: echo "DESTROY_STANDARD=${{ vars.DESTROY_STANDARD }}" >> $GITHUB_ENV
- name: Override Deployment Region
if: ${{vars.REGION_STANDARD != 0 }}
run: echo "REGION=${{ vars.REGION_STANDARD }}" >> $GITHUB_ENV
- name: Override Name Prefix
if: ${{vars.NAME_PREFIX_STANDARD != 0 }}
run: echo "NAME_PREFIX=${{ vars.NAME_PREFIX_STANDARD }}" >> $GITHUB_ENV
- name: Override Environment Token
if: ${{vars.ENVIRONMENT_STANDARD != 0 }}
run: echo "ENVIRONMENT=${{ vars.ENVIRONMENT_STANDARD }}" >> $GITHUB_ENV
- name: Override Jump Box Username
if: ${{vars.JUMP_BOX_USERNAME != 0 }}
run: echo "JUMP_BOX_USERNAME=${{ vars.JUMP_BOX_USERNAME }}" >> $GITHUB_ENV
- name: Override MySQl Admin Username
if: ${{vars.MYSQL_ADMIN_USERNAME != 0 }}
run: echo "MYSQL_ADMIN_USERNAME=${{ vars.MYSQL_ADMIN_USERNAME }}" >> $GITHUB_ENV
deploy_hub_network:
name: Deploy 02 Hub Network
needs: conditions
runs-on: ubuntu-latest
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/02-Hub-Network
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}"
- name: Terraform Apply
run: terraform apply my.plan
deploy_lz_network:
needs: [deploy_hub_network, conditions]
name: Deploy 03 LZ Network
runs-on: ubuntu-latest
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
outputs:
spoke_vnet_name: ${{ steps.output.outputs.spoke_vnet_name }}
spoke_rg: ${{ steps.output.outputs.spoke_rg }}
private_dns_rg: ${{ steps.output.outputs.private_dns_rg }}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/03-LZ-Network
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}"
- name: Terraform Apply
run: terraform apply my.plan
- name: Terraform Output
id: output
run: |
echo spoke_vnet_name=$(terraform output -raw spoke_vnet_name) >> $GITHUB_OUTPUT
echo spoke_rg=$(terraform output -raw spoke_rg) >> $GITHUB_OUTPUT
echo private_dns_rg=$(terraform output -raw private_dns_rg) >> $GITHUB_OUTPUT
deploy_lz_shared:
needs: [deploy_lz_network, conditions]
name: Deploy 04 LZ Shared Resources
runs-on: ubuntu-latest
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
JUMP_BOX_USERNAME: ${{ needs.conditions.outputs.jumpbox_username}}
outputs:
shared_rg: ${{ steps.output.outputs.shared_rg }}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/04-LZ-SharedResources
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}" \
-var="jump_host_admin_username=${{ env.JUMP_BOX_USERNAME }}" \
-var="jump_host_password=${{ env.JUMP_BOX_PASSWORD}}"
- name: Terraform Apply
run: terraform apply my.plan
- name: Terraform Output
id: output
run: |
echo shared_rg=$(terraform output -raw shared_rg) >> $GITHUB_OUTPUT
deploy_hub_firewall:
needs: [deploy_hub_network, deploy_lz_shared, conditions]
name: Deploy 05 Hub Firewall
runs-on: ubuntu-latest
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/05-Hub-AzureFirewall
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}"
- name: Terraform Apply
if: needs.conditions.outputs.deploy_firewall == 'true'
run: terraform apply my.plan
deploy_lz_standard:
needs:
[deploy_hub_network, deploy_lz_shared, deploy_hub_firewall, conditions]
name: Deploy 06 LZ Spring Apps Standard
runs-on: ubuntu-latest
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
outputs:
spring_apps_service_name: ${{ steps.output.outputs.spring_apps_service_name }}
spring_apps_rg: ${{ steps.output.outputs.spring_apps_rg }}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/06-LZ-SpringApps-Standard
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}"
- name: Terraform Apply
run: terraform apply my.plan
- name: Terraform Output
id: output
run: |
echo spring_apps_service_name=$(terraform output -raw spring_apps_service_name) >> $GITHUB_OUTPUT
echo spring_apps_rg=$(terraform output -raw spring_apps_rg) >> $GITHUB_OUTPUT
deploy_pet_clinic_infra:
name: Deploy Pet Clinic Infrastructure
needs: [deploy_lz_standard, deploy_lz_shared, deploy_lz_network, conditions]
runs-on: ubuntu-latest
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
MYSQL_ADMIN_USERNAME: ${{needs.conditions.outputs.mysql_admin_name}}
defaults:
run:
working-directory: Scenarios/sample-apps/petclinic/terraform
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -out my.plan \
-var="spring_cloud_service=${{ needs.deploy_lz_standard.outputs.spring_apps_service_name }}" \
-var="spring_cloud_resource_group_name=${{ needs.deploy_lz_standard.outputs.spring_apps_rg }}" \
-var="subscription_id=${{ env.SUBSCRIPTION_ID}}" \
-var="mysql_server_admin_password=${{ env.MYSQL_ADMIN_PASSWORD }}" \
-var="mysql_server_admin_username=${{ env.MYSQL_ADMIN_USERNAME }}" \
-var="resource_group=${{ needs.deploy_lz_network.outputs.spoke_rg }}" \
-var="vnet_spoke_name=${{ needs.deploy_lz_network.outputs.spoke_vnet_name }}" \
-var="private_zones_resource_group_name=${{ needs.deploy_lz_network.outputs.private_dns_rg }}" \
-var="key_vault_rg=${{ needs.deploy_lz_shared.outputs.shared_rg }}"
- name: Terraform Apply
run: terraform apply my.plan
build:
name: Build and Deploy Pet Clinic Microservices
needs: [deploy_pet_clinic_infra, deploy_lz_standard, conditions]
runs-on: ubuntu-latest
env:
SPRING_APPS_SERVICE_NAME: ${{ needs.deploy_lz_standard.outputs.spring_apps_service_name }}
steps:
- name: Checkout pet clinic sample
uses: actions/checkout@v3
with:
repository: Azure-Samples/spring-petclinic-microservices.git
path: pet-clinic
ref: azure
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: "microsoft"
cache: maven
- name: maven build, clean
working-directory: pet-clinic
run: |
mvn clean package -DskipTests
- name: Azure CLI Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Install Azure CLI Spring Extension
run: |
az extension add --name spring -y
az spring list -o table
az account set --subscription ${{ env.ARM_SUBSCRIPTION_ID }}
az configure --defaults group=${{ needs.deploy_lz_standard.outputs.spring_apps_rg }} spring=${{ needs.deploy_lz_standard.outputs.spring_apps_service_name }}
- name: Deploy api-gateway
run: |
az spring app deploy \
--resource-group ${{ needs.deploy_lz_standard.outputs.spring_apps_rg}} \
--service ${{ needs.deploy_lz_standard.outputs.spring_apps_service_name }} \
--name ${{ env.API_GATEWAY }} \
--artifact-path ${{ github.workspace }}/pet-clinic/${{ env.API_GATEWAY_JAR }} \
--jvm-options='-Xms2048m -Xmx2048m' \
--env SPRING_PROFILES_ACTIVE=passwordless
- name: Deploy admin-server
run: |
az spring app deploy \
--resource-group ${{ needs.deploy_lz_standard.outputs.spring_apps_rg}} \
--service ${{ needs.deploy_lz_standard.outputs.spring_apps_service_name }} \
--name ${{ env.ADMIN_SERVER }} \
--artifact-path ${{ github.workspace }}/pet-clinic/${{ env.ADMIN_SERVER_JAR }} \
--jvm-options='-Xms2048m -Xmx2048m' \
--env SPRING_PROFILES_ACTIVE=passwordless
- name: Deploy customers-service
run: |
az spring app deploy \
--resource-group ${{ needs.deploy_lz_standard.outputs.spring_apps_rg}} \
--service ${{ needs.deploy_lz_standard.outputs.spring_apps_service_name }} \
--name ${{ env.CUSTOMERS_SERVICE }} \
--artifact-path ${{ github.workspace }}/pet-clinic/${{ env.CUSTOMERS_SERVICE_JAR }} \
--jvm-options='-Xms2048m -Xmx2048m' \
--env SPRING_PROFILES_ACTIVE=passwordless
- name: Deploy vets-service
run: |
az spring app deploy \
--resource-group ${{ needs.deploy_lz_standard.outputs.spring_apps_rg}} \
--service ${{ needs.deploy_lz_standard.outputs.spring_apps_service_name }} \
--name ${{ env.VETS_SERVICE }} \
--artifact-path ${{ github.workspace }}/pet-clinic/${{ env.VETS_SERVICE_JAR }} \
--jvm-options='-Xms2048m -Xmx2048m' \
--env SPRING_PROFILES_ACTIVE=passwordless
- name: Deploy visits-service
run: |
az spring app deploy \
--resource-group ${{ needs.deploy_lz_standard.outputs.spring_apps_rg}} \
--service ${{ needs.deploy_lz_standard.outputs.spring_apps_service_name }} \
--name ${{ env.VISITS_SERVICE}} \
--artifact-path ${{ github.workspace }}/pet-clinic/${{ env.VISITS_SERVICE_JAR }} \
--jvm-options='-Xms2048m -Xmx2048m' \
--env SPRING_PROFILES_ACTIVE=passwordless
destroy_pet_clinic_infra:
name: Destroy Pet Clinic Infrastructure
needs:
[
conditions,
deploy_lz_standard,
deploy_lz_network,
deploy_lz_shared,
deploy_pet_clinic_infra,
build,
]
runs-on: ubuntu-latest
if: ${{ always() && needs.conditions.outputs.destroy == 'true'}}
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
MYSQL_ADMIN_USERNAME: ${{needs.conditions.outputs.mysql_admin_name}}
defaults:
run:
working-directory: Scenarios/sample-apps/petclinic/terraform
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -destroy -out my.plan \
-var="spring_cloud_service=${{ needs.deploy_lz_standard.outputs.spring_apps_service_name }}" \
-var="spring_cloud_resource_group_name=${{ needs.deploy_lz_standard.outputs.spring_apps_rg }}" \
-var="subscription_id=${{ env.SUBSCRIPTION_ID}}" \
-var="mysql_server_admin_password=${{ env.MYSQL_ADMIN_PASSWORD }}" \
-var="mysql_server_admin_username=${{ env.MYSQL_ADMIN_USERNAME }}" \
-var="resource_group=${{ needs.deploy_lz_network.outputs.spoke_rg }}" \
-var="vnet_spoke_name=${{ needs.deploy_lz_network.outputs.spoke_vnet_name }}" \
-var="private_zones_resource_group_name=${{ needs.deploy_lz_network.outputs.private_dns_rg }}" \
-var="key_vault_rg=${{ needs.deploy_lz_shared.outputs.shared_rg }}"
- name: Terraform Apply
run: terraform apply my.plan
destroy_lz_standard:
needs: [conditions, deploy_lz_standard, destroy_pet_clinic_infra]
name: Destroy 06 LZ Spring Apps Standard
runs-on: ubuntu-latest
if: ${{ always() && needs.conditions.outputs.destroy == 'true'}}
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
MYSQL_ADMIN_USERNAME: ${{needs.conditions.outputs.mysql_admin_name}}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/06-LZ-SpringApps-Standard
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -destroy -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}"
- name: Terraform Apply
run: terraform apply my.plan
destroy_hub_firewall:
needs: [destroy_lz_standard, conditions]
name: Destroy 05 Hub Firewall
runs-on: ubuntu-latest
if: ${{ always() && needs.conditions.outputs.destroy == 'true'}}
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
MYSQL_ADMIN_USERNAME: ${{needs.conditions.outputs.mysql_admin_name}}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/05-Hub-AzureFirewall
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -destroy -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}"
- name: Terraform Apply
run: terraform apply my.plan
destroy_lz_shared:
needs: [destroy_hub_firewall, conditions]
name: Destroy 04 LZ Shared Resources
runs-on: ubuntu-latest
if: ${{ always() && needs.conditions.outputs.destroy == 'true'}}
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
JUMP_BOX_USERNAME: ${{needs.conditions.outputs.jumpbox_username}}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/04-LZ-SharedResources
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -destroy -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}" \
-var="jump_host_admin_username=${{ env.JUMP_BOX_USERNAME }}" \
-var="jump_host_password=${{ env.JUMP_BOX_PASSWORD}}"
- name: Terraform Apply
run: terraform apply my.plan
destroy_lz_network:
needs: [destroy_lz_shared, conditions]
name: Destroy 03 LZ Network
runs-on: ubuntu-latest
if: ${{ always() && needs.conditions.outputs.destroy == 'true'}}
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/03-LZ-Network
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -destroy -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}"
- name: Terraform Apply
run: terraform apply my.plan
destroy_hub_network:
name: Destroy 02 Hub Network
needs: [destroy_lz_network, conditions]
runs-on: ubuntu-latest
if: ${{ always() && needs.conditions.outputs.destroy == 'true'}}
env:
NAME_PREFIX: ${{needs.conditions.outputs.name_prefix}}
ENVIRONMENT: ${{needs.conditions.outputs.environment}}
REGION: ${{ needs.conditions.outputs.region}}
defaults:
run:
working-directory: Scenarios/ASA-Secure-Baseline/Terraform/02-Hub-Network
steps:
- name: Checkout this repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
with:
terraform_wrapper: false
terraform_version: 1.5.7
- name: Terraform Init
run: |
terraform init \
-backend-config="resource_group_name=${{ env.TFSTATE_RG }}" \
-backend-config="storage_account_name=${{ env.STORAGEACCOUNTNAME }}" \
-backend-config="container_name=${{ env.CONTAINERNAME }}"
- name: Terraform Plan
run: |
terraform plan -destroy -out my.plan \
-var="state_sa_rg=${{ env.TFSTATE_RG }}" \
-var="state_sa_name=${{ env.STORAGEACCOUNTNAME }}" \
-var="state_sa_container_name=${{ env.CONTAINERNAME }}" \
-var="location=${{ env.REGION }}" \
-var="name_prefix=${{ env.NAME_PREFIX }}" \
-var="environment=${{ env.ENVIRONMENT }}" \
-var="SPRINGAPPS_SPN_OBJECT_ID=${{ env.SPRINGAPPS_SPN_OBJECT_ID }}"
- name: Terraform Apply
run: terraform apply my.plan