-
Notifications
You must be signed in to change notification settings - Fork 2
1736 lines (1562 loc) · 66.8 KB
/
e2e.yml
File metadata and controls
1736 lines (1562 loc) · 66.8 KB
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
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: E2E Integration Tests
on:
# Manual-only trigger. Pre-GA the repo isn't customer-facing yet,
# so authors run E2E on demand at the end of a sprint or when a PR
# touches the Lambda/CFN. Layer 1 (sync-check, handler coverage,
# cfn-lint) stays as the per-PR gate.
workflow_dispatch:
# Serialize all E2E runs — the linked-account pool (linked2–5) is shared
# across every run, so two concurrent runs race to tag each other's
# resources. Queue instead of cancel: an interrupted run would skip
# teardown and leave StackSets + Lambdas behind.
concurrency:
group: e2e-linked-accounts-pool
cancel-in-progress: false
# Default settings inherited by all jobs
defaults:
run:
working-directory: .github/scripts
env:
# Falls back to run_id for schedule/workflow_dispatch runs (no PR).
# Keeps resource names unique across runs so nothing collides.
PR_NUMBER: ${{ github.event.pull_request.number || github.run_id }}
# MPE_ID drives the expected tag value. Keeps the `migTEST` prefix so the
# scope-vpc-positive verify step (which filters tags by `migTEST*`) keeps
# working — scope tests run in the same account as the main stack and both
# Lambdas race to tag the same resource; last-writer wins, and the prefix
# match is what absorbs the race. Appends the run ID so resource names
# (IAM role, Lambda, SQS, SSM) are unique per workflow run and we don't hit
# "already exists" collisions when two runs overlap. Fixed in PR #4, lost
# when PR #5 merged on top of an older main; restoring here.
# Length check: `map-auto-tagger-role-migTEST<11-digit-run-id>-ap-northeast-2`
# = 61 chars, safely under the 64-char IAM role name limit.
MPE_ID: migTEST${{ github.run_id }}
# Scope test MPEs — also per-run (not static) to prevent cross-PR
# collisions in linked1 (which now hosts all scope stacks). Fixed
# suffixes (A/B/C/D) distinguish the four scope stacks inside a
# single run while keeping the migTEST prefix so verify-scope-*
# prefix-match still works.
SCOPE_ACCT_MPE: migTEST${{ github.run_id }}A
SCOPE_VPC_MPE: migTEST${{ github.run_id }}B
SCOPE_DATE_MPE: migTEST${{ github.run_id }}C
SCOPE_ACCT_OUT_MPE: migTEST${{ github.run_id }}D
STACK_NAME: map-auto-tagger-e2e-pr${{ github.event.pull_request.number || github.run_id }}
# ---------------------------------------------------------------------------
# Reusable step fragments — referenced by name in jobs below
# ---------------------------------------------------------------------------
# ── AWS credentials helper ─────────────────────────────────────────────────
# Every job includes these three steps at the top.
# Multi-account jobs override role-to-assume.
jobs:
# ══════════════════════════════════════════════════════════════════════════
# Phase 1 — Deploy the auto-tagger itself (runs in parallel)
# ══════════════════════════════════════════════════════════════════════════
deploy-single:
name: Deploy single-account stack
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Wait for any previous stack deletions to complete
working-directory: .
run: |
for REGION in ap-northeast-2 us-east-1 us-west-2; do
STATUS=$(aws cloudformation describe-stacks \
--stack-name "$STACK_NAME" --region "$REGION" \
--query 'Stacks[0].StackStatus' --output text 2>/dev/null || echo "DOES_NOT_EXIST")
if [ "$STATUS" = "DELETE_IN_PROGRESS" ]; then
echo "Waiting for $STACK_NAME deletion in $REGION..."
aws cloudformation wait stack-delete-complete \
--stack-name "$STACK_NAME" --region "$REGION" || true
fi
done
- name: Deploy auto-tagger CloudFormation stack
working-directory: .
run: |
# Template is >51KB — stage in S3 per region (buckets must be co-located)
ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
for REGION in ap-northeast-2 us-east-1 us-west-2; do
S3_BUCKET="cfn-e2e-${ACCOUNT}-${PR_NUMBER}-${REGION}"
# us-east-1 does not accept LocationConstraint
if [ "$REGION" = "us-east-1" ]; then
aws s3api create-bucket --bucket "$S3_BUCKET" --region us-east-1 2>/dev/null || true
else
aws s3api create-bucket \
--bucket "$S3_BUCKET" \
--region "$REGION" \
--create-bucket-configuration LocationConstraint="$REGION" \
2>/dev/null || true
fi
aws cloudformation deploy \
--stack-name "${STACK_NAME}" \
--template-file map2-auto-tagger-optimized.yaml \
--parameter-overrides \
MpeId="$MPE_ID" \
AgreementStartDate="2024-01-01" \
--capabilities CAPABILITY_NAMED_IAM \
--s3-bucket "$S3_BUCKET" \
--s3-prefix "e2e" \
--region "$REGION" \
--no-fail-on-empty-changeset
done
- name: Verify stack is deployed
working-directory: .
run: |
STATUS=$(aws cloudformation describe-stacks \
--stack-name "$STACK_NAME" \
--query 'Stacks[0].StackStatus' --output text)
echo "Stack status: $STATUS"
if [[ "$STATUS" != *"COMPLETE"* ]]; then
echo "Stack not in a successful state: $STATUS"
exit 1
fi
deploy-stackset:
name: Deploy multi-account StackSet
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_MGMT_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Clean up stale StackSets from prior PR runs
run: |
# Delete any map-auto-tagger-e2e-pr*-stackset StackSets that are NOT
# the current PR's StackSet. Orphaned instances from prior runs cause
# CAPABILITY_NAMED_IAM conflicts (IAM role / log group name collision).
CURRENT_SS="$STACK_NAME-stackset"
for ss in $(aws cloudformation list-stack-sets \
--status ACTIVE \
--query 'Summaries[?starts_with(StackSetName, `map-auto-tagger-e2e-pr`)].StackSetName' \
--output text \
--region ap-northeast-2 2>/dev/null); do
if [ "$ss" = "$CURRENT_SS" ]; then
echo "Skipping current StackSet: $ss"
continue
fi
echo "Cleaning up stale StackSet: $ss"
python3 delete_stackset.py \
--name "$ss" \
--accounts "${{ secrets.E2E_LINKED_ACCOUNT_IDS }}" \
--org-unit-ids "${{ secrets.AWS_SANDBOX_OU_ID }}" \
--region ap-northeast-2 || true
done
continue-on-error: true
- name: Deploy StackSet to linked accounts
run: |
# PR #7.b: linked1 is reserved for scope tests (isolation from the
# main StackSet Lambda). Strip linked1 from the StackSet targets
# so no main Lambda runs there and scope Lambdas don't race.
ACCOUNTS=$(echo "${{ secrets.E2E_LINKED_ACCOUNT_IDS }}" | tr ',' '\n' | grep -v "^${{ secrets.AWS_LINKED1_ACCOUNT_ID }}$" | paste -sd, -)
echo "StackSet target accounts (linked1 excluded): $ACCOUNTS"
python3 deploy_stackset.py \
--stack-set-name "$STACK_NAME-stackset" \
--template ../../map2-auto-tagger-optimized.yaml \
--mpe-id "$MPE_ID" \
--agreement-date "2024-01-01" \
--accounts "$ACCOUNTS" \
--org-unit-ids "${{ secrets.AWS_SANDBOX_OU_ID }}" \
--region ap-northeast-2
# ══════════════════════════════════════════════════════════════════════════
# Phase 2 — Create test resources (all parallel, each group independent)
# ══════════════════════════════════════════════════════════════════════════
create-networking:
name: Create networking resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
outputs:
vpc-id: ${{ steps.create.outputs.vpc-id }}
subnet-ids: ${{ steps.create.outputs.subnet-ids }}
sg-id: ${{ steps.create.outputs.sg-id }}
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create networking resources
id: create
run: |
python3 create_resources.py \
--group networking \
--region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-networking
path: .github/scripts/created-arns-networking.json
if-no-files-found: warn
create-core:
name: Create core compute resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create core resources
run: |
python3 create_resources.py --group core --region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-core
path: .github/scripts/created-arns-core.json
if-no-files-found: warn
create-databases:
name: Create database resources
runs-on: ubuntu-latest
needs: [deploy-single, create-networking]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create database resources
run: |
python3 create_resources.py \
--group databases \
--region ap-northeast-2 \
--vpc-id "${{ needs.create-networking.outputs.vpc-id }}" \
--subnet-ids "${{ needs.create-networking.outputs.subnet-ids }}" \
--sg-id "${{ needs.create-networking.outputs.sg-id }}"
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-databases
path: .github/scripts/created-arns-databases.json
if-no-files-found: warn
create-analytics:
name: Create analytics resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create analytics resources
run: |
python3 create_resources.py --group analytics --region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-analytics
path: .github/scripts/created-arns-analytics.json
if-no-files-found: warn
create-integration:
name: Create integration resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create integration resources
run: |
python3 create_resources.py --group integration --region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-integration
path: .github/scripts/created-arns-integration.json
if-no-files-found: warn
create-security:
name: Create security resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create security resources
run: |
python3 create_resources.py --group security --region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-security
path: .github/scripts/created-arns-security.json
if-no-files-found: warn
create-devtools:
name: Create devtools resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create devtools resources
run: |
python3 create_resources.py --group devtools --region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-devtools
path: .github/scripts/created-arns-devtools.json
if-no-files-found: warn
create-ml:
name: Create ML/AI resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create ML resources
run: |
python3 create_resources.py --group ml --region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-ml
path: .github/scripts/created-arns-ml.json
if-no-files-found: warn
create-media-iot:
name: Create media and IoT resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create media and IoT resources
run: |
python3 create_resources.py --group media-iot --region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-media-iot
path: .github/scripts/created-arns-media-iot.json
if-no-files-found: warn
create-misc:
name: Create miscellaneous resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create miscellaneous resources
run: |
python3 create_resources.py --group misc --region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-misc
path: .github/scripts/created-arns-misc.json
if-no-files-found: warn
create-global-us-east-1:
name: Create global us-east-1 resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: us-east-1
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create global us-east-1 resources
run: |
python3 create_resources.py --group global-us-east-1 --region us-east-1
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-global-us-east-1
path: .github/scripts/created-arns-global-us-east-1.json
if-no-files-found: warn
create-global-us-west-2:
name: Create global us-west-2 resources
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: us-west-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create global us-west-2 resources
run: |
python3 create_resources.py --group global-us-west-2 --region us-west-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-global-us-west-2
path: .github/scripts/created-arns-global-us-west-2.json
if-no-files-found: warn
# ── Multi-account linked account resource creation ────────────────────────
# Each linked account job assumes a separate role specific to that account.
# PR #7.b: linked1 is reserved for scope tests — no main-Lambda resources
# are created there. Scope tests create their own resources in linked1
# (see deploy-scope-* jobs).
create-multiaccount-linked2:
name: Create resources in linked account 2
runs-on: ubuntu-latest
needs: [deploy-stackset]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_LINKED2_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create resources in linked account 2
run: |
python3 create_resources.py \
--group multiaccount-linked2 \
--account-index 2 \
--region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-multiaccount-linked2
path: .github/scripts/created-arns-multiaccount-linked2.json
if-no-files-found: warn
create-multiaccount-linked3:
name: Create resources in linked account 3
runs-on: ubuntu-latest
needs: [deploy-stackset]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_LINKED3_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create resources in linked account 3
run: |
python3 create_resources.py \
--group multiaccount-linked3 \
--account-index 3 \
--region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-multiaccount-linked3
path: .github/scripts/created-arns-multiaccount-linked3.json
if-no-files-found: warn
create-multiaccount-linked4:
name: Create resources in linked account 4
runs-on: ubuntu-latest
needs: [deploy-stackset]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_LINKED4_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create resources in linked account 4
run: |
python3 create_resources.py \
--group multiaccount-linked4 \
--account-index 4 \
--region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-multiaccount-linked4
path: .github/scripts/created-arns-multiaccount-linked4.json
if-no-files-found: warn
create-multiaccount-linked5:
name: Create resources in linked account 5
runs-on: ubuntu-latest
needs: [deploy-stackset]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_LINKED5_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- name: Create resources in linked account 5
run: |
python3 create_resources.py \
--group multiaccount-linked5 \
--account-index 5 \
--region ap-northeast-2
- uses: actions/upload-artifact@v4
if: always()
with:
name: arns-multiaccount-linked5
path: .github/scripts/created-arns-multiaccount-linked5.json
if-no-files-found: warn
# ══════════════════════════════════════════════════════════════════════════
# Phase 2b — StackSet Lambda health + linked-account tag verification (PR #7.c)
# ══════════════════════════════════════════════════════════════════════════
# One matrix entry per linked account (2-5). Each entry:
# 1. assumes the linked account's GitHubActionsE2ERole
# 2. proves the StackSet-deployed Lambda is actually running
# (get_function + Invocations > 0 + DLQ empty)
# 3. runs verify_tags.py against the linked account's own ARN artifact
# to confirm resources in that account got the map-migrated tag
#
# Why this exists:
# a) The StackSet deploy only proves CloudFormation succeeded in the mgmt
# account's view. A Lambda can still be broken per linked account
# (IAM drift, KMS denial, partial rollback). This catches that.
# b) Before PR #7.c the main `verify` job never actually checked the
# linked-account resources' tags — the single-account GH Actions
# role can't sts:AssumeRole into linked accounts, so verify_tags
# silently skipped them. Customers deploying the StackSet in prod
# had no E2E guarantee that the Lambda actually tagged their linked
# account resources. This closes that loop.
verify-linked-account:
name: Verify linked${{ matrix.index }} Lambda + tags
runs-on: ubuntu-latest
needs:
- create-multiaccount-linked2
- create-multiaccount-linked3
- create-multiaccount-linked4
- create-multiaccount-linked5
strategy:
fail-fast: false
matrix:
include:
- index: 2
account_secret: AWS_LINKED2_ACCOUNT_ID
- index: 3
account_secret: AWS_LINKED3_ACCOUNT_ID
- index: 4
account_secret: AWS_LINKED4_ACCOUNT_ID
- index: 5
account_secret: AWS_LINKED5_ACCOUNT_ID
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets[matrix.account_secret] }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
- uses: actions/download-artifact@v4
with:
name: arns-multiaccount-linked${{ matrix.index }}
path: artifacts/
- name: Assert StackSet-deployed Lambda is healthy
run: |
python3 assert_tagger_health.py \
--mpe-id "$MPE_ID" \
--region ap-northeast-2 \
--window-minutes 20 \
--min-invocations 1
- name: Verify linked${{ matrix.index }} resources are tagged
run: |
python3 verify_tags.py \
--arns-dir ../../artifacts/ \
--tag-key map-migrated \
--tag-value "$MPE_ID" \
--max-wait 600 \
--poll-interval 30
working-directory: .github/scripts
# ══════════════════════════════════════════════════════════════════════════
# Phase 3 — Verify tags (runs after all create jobs)
# ══════════════════════════════════════════════════════════════════════════
verify:
name: Verify map-migrated tags
runs-on: ubuntu-latest
needs:
- create-networking
- create-core
- create-databases
- create-analytics
- create-integration
- create-security
- create-devtools
- create-ml
- create-media-iot
- create-misc
- create-global-us-east-1
- create-global-us-west-2
# linked1 intentionally omitted: reserved for scope tests (PR #7.b)
- create-multiaccount-linked2
- create-multiaccount-linked3
- create-multiaccount-linked4
- create-multiaccount-linked5
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install boto3
# Download single-account and multi-account ARN artifacts only
# Scope test artifacts (arns-scope-*) are verified by their own jobs
- uses: actions/download-artifact@v4
with:
pattern: arns-networking
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-core
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-databases
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-analytics
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-integration
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-security
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-devtools
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-ml
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-media-iot
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-misc
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-global-us-east-1
path: artifacts/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: arns-global-us-west-2
path: artifacts/
merge-multiple: true
- name: List downloaded ARN files
run: ls -la artifacts/ || echo "No artifacts directory"
working-directory: .
# Fast-fail signal: if the Lambda has not been invoked at all or its
# DLQ is full, abort in ~10s instead of letting verify_tags poll for 900s.
# Before PR #7.a, resources were pre-tagged with `map-migrated` so verify
# always passed regardless of Lambda state — a broken Lambda could ship
# undetected. This step + the pre-tagging removal are the real gate now.
- name: Assert auto-tagger Lambda is healthy
run: |
python3 assert_tagger_health.py \
--mpe-id "$MPE_ID" \
--region ap-northeast-2 \
--window-minutes 15 \
--min-invocations 1
- name: Verify tags on all resources
run: |
python3 verify_tags.py \
--arns-dir ../../artifacts/ \
--tag-key map-migrated \
--tag-value "$MPE_ID" \
--max-wait 900 \
--poll-interval 30
- uses: actions/upload-artifact@v4
if: always()
with:
name: verification-report
path: .github/scripts/verification-report.json
if-no-files-found: warn
# ══════════════════════════════════════════════════════════════════════════
# Phase 3b — deploy.sh generation + execution test
# Tests that configurator.html generates a working deploy.sh (not just the YAML)
# ══════════════════════════════════════════════════════════════════════════
test-deploy-sh:
name: Test deploy.sh generation and execution
runs-on: ubuntu-latest
needs: [deploy-single]
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_SINGLE_ACCOUNT_ID }}:role/GitHubActionsE2ERole
aws-region: ap-northeast-2
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Playwright
working-directory: .
run: npm install playwright && npx playwright install chromium --with-deps
- name: Generate deploy.sh from configurator.html
working-directory: .
run: |
# Use a DIFFERENT MPE ID to avoid IAM role name collision with main E2E stack
# (both stacks would create map-auto-tagger-role-${MpeId}-ap-northeast-2)
DEPLOY_SH_MPE="migTEST9999999"
node .github/scripts/generate_deploy_sh.js \
--mpe-id "$DEPLOY_SH_MPE" \