Skip to content

Commit 933ee94

Browse files
authored
feat(gen2-migration): gen2 migration codebuild e2e workflow (#14791)
* add teardown option to remove created amplify and cfn resources * gen2-migration e2e automation * remove backend-data dep from amplify-cli, no longer used * comment updates * fix: credentials expire after tests but before cleanup * fix: s3 buckets are not empty on deletion attempts during cleanup * fix: custom resources referring to moved gen1 resources fail to delete * fix: deleting gen2 app before gen1 app can cause custom resource deletion failure in gen1 * feat: --roleArn option to run the gen2-migration E2E tests, to allow credential refresh in CI * fix: cleanup was using wrong credentials * fix: test credential role-chaining failure * fix: custom auth trigger lambda was not deleted in teardown * review changes * teardown logic should rediscover stacks in every deletion loop * fix: snapshot takes credentials from execution environment rather than explicitly specified credentials * fix: profile not always passed through * review changes * be extra safe we are using the profile in CodeBuild for cleanup
1 parent ebccf0e commit 933ee94

27 files changed

Lines changed: 864 additions & 48 deletions

File tree

amplify-migration-apps/backend-only/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"typecheck": "cd _snapshot.post.generate/amplify && npx tsc --noEmit",
1414
"test:gen1": "true",
1515
"test:gen2": "true",
16+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app backend-only --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
1617
"test:shared": "true",
17-
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app backend-only --profile ${AWS_PROFILE:-default}",
1818
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app backend-only --step deploy --profile ${AWS_PROFILE:-default}",
1919
"pre-push": "true",
2020
"post-generate": "npx tsx migration/post-generate.ts",

amplify-migration-apps/discussions/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
2020
"test:shared": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts tests/shared-auth.test.ts",
2121
"test:shared-data": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts",
22+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app discussions --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
2223
"test:shared-auth": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-auth.test.ts",
23-
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app discussions --profile ${AWS_PROFILE:-default}",
24-
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app discussions --step deploy --profile ${AWS_PROFILE:-default}",
2524
"pre-push": "true",
2625
"post-generate": "npx tsx migration/post-generate.ts",
2726
"post-refactor": "npx tsx migration/post-refactor.ts",

amplify-migration-apps/fitness-tracker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"sanitize": "tsx ../sanitize.ts",
1818
"normalize": "tsx ../normalize.ts",
1919
"typecheck": "cd _snapshot.post.generate/amplify && npx tsc --noEmit",
20+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app fitness-tracker --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
2021
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
2122
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
2223
"test:shared": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts tests/shared-auth.test.ts",
2324
"test:shared-data": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts",
2425
"test:shared-auth": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-auth.test.ts",
25-
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app fitness-tracker --profile ${AWS_PROFILE:-default}",
2626
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app fitness-tracker --step deploy --profile ${AWS_PROFILE:-default}",
2727
"pre-push": "npx tsx migration/pre-push.ts",
2828
"post-generate": "npx tsx migration/post-generate.ts",

amplify-migration-apps/imported-resources/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
"typecheck": "cd _snapshot.post.generate/amplify && npx tsc --noEmit",
1919
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
2020
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
21+
"test:shared-data": "true",
22+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app imported-resources --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
2123
"test:shared": "true",
22-
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app imported-resources --profile ${AWS_PROFILE:-default}",
2324
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app imported-resources --step deploy --profile ${AWS_PROFILE:-default}",
2425
"pre-push": "true",
2526
"post-generate": "npx tsx migration/post-generate.ts",

amplify-migration-apps/media-vault/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
"typecheck": "cd _snapshot.post.generate/amplify && npx tsc --noEmit",
1818
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
1919
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
20+
"test:shared-data": "true",
21+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app media-vault --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
2022
"test:shared": "true",
21-
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app media-vault --profile ${AWS_PROFILE:-default}",
2223
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app media-vault --step deploy --profile ${AWS_PROFILE:-default}",
2324
"pre-push": "npx tsx migration/pre-push.ts",
2425
"post-generate": "npx tsx migration/post-generate.ts",

amplify-migration-apps/mood-board/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
"sanitize": "tsx ../sanitize.ts",
1515
"normalize": "tsx ../normalize.ts",
1616
"typecheck": "cd _snapshot.post.generate/amplify && npx tsc --noEmit",
17+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app mood-board --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
1718
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
1819
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
1920
"test:shared-data": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts",
2021
"test:shared-auth": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-auth.test.ts",
2122
"test:shared": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts tests/shared-auth.test.ts",
22-
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app mood-board --profile ${AWS_PROFILE:-default}",
2323
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app mood-board --step deploy --profile ${AWS_PROFILE:-default}",
2424
"pre-push": "true",
2525
"post-generate": "npx tsx migration/post-generate.ts",

amplify-migration-apps/product-catalog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"sanitize": "tsx ../sanitize.ts",
1616
"normalize": "tsx ../normalize.ts",
1717
"typecheck": "cd _snapshot.post.generate/amplify && npx tsc --noEmit",
18+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app product-catalog --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
1819
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
1920
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
2021
"test:shared": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts tests/shared-auth.test.ts",
2122
"test:shared-data": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts",
2223
"test:shared-auth": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-auth.test.ts",
23-
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app product-catalog --profile ${AWS_PROFILE:-default}",
2424
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app product-catalog --step deploy --profile ${AWS_PROFILE:-default}",
2525
"pre-push": "npx tsx migration/pre-push.ts",
2626
"post-generate": "npx tsx migration/post-generate.ts",

amplify-migration-apps/project-boards/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"sanitize": "tsx ../sanitize.ts",
1616
"normalize": "tsx ../normalize.ts",
1717
"typecheck": "cd _snapshot.post.generate/amplify && npx tsc --noEmit",
18+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app project-boards --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
1819
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
1920
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
2021
"test:shared": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts tests/shared-auth.test.ts",
2122
"test:shared-data": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts",
2223
"test:shared-auth": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-auth.test.ts",
23-
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app project-boards --profile ${AWS_PROFILE:-default}",
2424
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app project-boards --step deploy --profile ${AWS_PROFILE:-default}",
2525
"pre-push": "true",
2626
"post-generate": "npx tsx migration/post-generate.ts",

amplify-migration-apps/store-locator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared'",
1919
"test:shared": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-auth.test.ts",
2020
"test:shared-data": "true",
21+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app store-locator --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
2122
"test:shared-auth": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-auth.test.ts",
22-
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app store-locator --profile ${AWS_PROFILE:-default}",
2323
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app store-locator --step deploy --profile ${AWS_PROFILE:-default}",
2424
"pre-push": "npx tsx migration/pre-push.ts",
2525
"post-generate": "npx tsx migration/post-generate.ts",
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Gen2 Migration PR Workflow
2+
#
3+
# This workflow executes the full migration E2E test for apps in amplify-migration-apps.
4+
#
5+
# Each migration test takes approximately 30 minutes and runs in parallel.
6+
# The workflow first builds the CLI binaries, then runs migration tests concurrently.
7+
#
8+
# To trigger this workflow, configure a CodeBuild project with:
9+
# - Buildspec: codebuild_specs/gen2_migration_e2e_pr_workflow.yml
10+
# - Environment variables: TEST_ACCOUNT_ROLE (IAM role ARN for test account)
11+
#
12+
version: 0.2
13+
env:
14+
shell: bash
15+
compute-type: BUILD_GENERAL1_MEDIUM
16+
variables:
17+
AWS_DEFAULT_REGION: us-east-1
18+
AWS_REGION: us-east-1
19+
CDK_DEFAULT_REGION: us-east-1
20+
CLI_REGION: us-east-1
21+
AMPLIFY_DIR: '$CODEBUILD_SRC_DIR/out'
22+
AMPLIFY_PATH: '$CODEBUILD_SRC_DIR/out/amplify-pkg-linux-x64'
23+
24+
batch:
25+
fast-fail: false
26+
build-graph:
27+
# Build phase - required for all migration tests
28+
- identifier: build_linux
29+
buildspec: codebuild_specs/build_linux.yml
30+
env:
31+
compute-type: BUILD_GENERAL1_LARGE
32+
33+
- identifier: publish_to_local_registry
34+
buildspec: codebuild_specs/publish_to_local_registry.yml
35+
depend-on:
36+
- build_linux
37+
env:
38+
compute-type: BUILD_GENERAL1_LARGE
39+
40+
- identifier: build_pkg_binaries_linux
41+
buildspec: codebuild_specs/build_pkg_binaries_linux.yml
42+
depend-on:
43+
- publish_to_local_registry
44+
env:
45+
compute-type: BUILD_GENERAL1_LARGE
46+
47+
- identifier: upb
48+
buildspec: codebuild_specs/upload_pkg_binaries_linux_only.yml
49+
depend-on:
50+
- build_pkg_binaries_linux
51+
env:
52+
compute-type: BUILD_GENERAL1_LARGE
53+
54+
# Migration E2E tests - run in parallel after binaries are ready
55+
# Each test takes ~30 minutes and deploys real AWS resources
56+
- identifier: migrate_backend_only
57+
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
58+
env:
59+
compute-type: BUILD_GENERAL1_LARGE
60+
variables:
61+
MIGRATION_APP: backend-only
62+
depend-on:
63+
- upb
64+
65+
- identifier: migrate_discussions
66+
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
67+
env:
68+
compute-type: BUILD_GENERAL1_LARGE
69+
variables:
70+
MIGRATION_APP: discussions
71+
depend-on:
72+
- upb
73+
74+
- identifier: migrate_fitness_tracker
75+
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
76+
env:
77+
compute-type: BUILD_GENERAL1_LARGE
78+
variables:
79+
MIGRATION_APP: fitness-tracker
80+
depend-on:
81+
- upb
82+
83+
# TODO: migrate_imported_resources is excluded - not ready for CI yet
84+
85+
- identifier: migrate_media_vault
86+
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
87+
env:
88+
compute-type: BUILD_GENERAL1_LARGE
89+
variables:
90+
MIGRATION_APP: media-vault
91+
depend-on:
92+
- upb
93+
94+
- identifier: migrate_mood_board
95+
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
96+
env:
97+
compute-type: BUILD_GENERAL1_LARGE
98+
variables:
99+
MIGRATION_APP: mood-board
100+
depend-on:
101+
- upb
102+
103+
- identifier: migrate_product_catalog
104+
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
105+
env:
106+
compute-type: BUILD_GENERAL1_LARGE
107+
variables:
108+
MIGRATION_APP: product-catalog
109+
depend-on:
110+
- upb
111+
112+
- identifier: migrate_project_boards
113+
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
114+
env:
115+
compute-type: BUILD_GENERAL1_LARGE
116+
variables:
117+
MIGRATION_APP: project-boards
118+
depend-on:
119+
- upb
120+
121+
- identifier: migrate_store_locator
122+
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
123+
env:
124+
compute-type: BUILD_GENERAL1_LARGE
125+
variables:
126+
MIGRATION_APP: store-locator
127+
depend-on:
128+
- upb

0 commit comments

Comments
 (0)