Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .circleci/local_publish_helpers_codebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ function generatePkgCli {
cp ../yarn.lock ./
yarn workspaces focus --production

# Workaround for yao-pkg/pkg#195: pkg's snapshot filesystem can't resolve
# ESM imports from .mjs files referenced by the "module-sync" export condition.
# We strip just the "module-sync" line from each affected package.json so pkg
# falls back to the "default" (CJS) condition instead.
for esm_pkg in async-function async-generator-function generator-function; do
pkg_dir="node_modules/$esm_pkg"
if [ -d "$pkg_dir" ]; then
sed -i.bak '/"module-sync"/d' "$pkg_dir/package.json" && rm -f "$pkg_dir/package.json.bak"
echo "Patched $esm_pkg: removed module-sync export (yao-pkg/pkg#195)"
fi
done

# Optimize package size
find . \
-name "*.d.ts" -or -name "*.js.map" -or -name "*.d.ts.map" -or \
Expand Down
2 changes: 1 addition & 1 deletion amplify-migration-apps/backend-only/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test:gen1": "true",
"test:gen2": "true",
"test:shared-data": "true",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app backend-only --profile ${AWS_PROFILE:-default}",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app backend-only --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app backend-only --step deploy --profile ${AWS_PROFILE:-default}",
"pre-push": "true",
"post-generate": "npx tsx migration/post-generate.ts",
Expand Down
2 changes: 1 addition & 1 deletion amplify-migration-apps/discussions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared-data'",
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose --testPathIgnorePatterns='shared-data'",
"test:shared-data": "NODE_OPTIONS='--experimental-vm-modules' jest --verbose tests/shared-data.test.ts",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app discussions --profile ${AWS_PROFILE:-default}",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app discussions --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app discussions --step deploy --profile ${AWS_PROFILE:-default}",
"pre-push": "true",
"post-generate": "npx tsx migration/post-generate.ts",
Expand Down
2 changes: 1 addition & 1 deletion amplify-migration-apps/fitness-tracker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:shared-data": "true",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app fitness-tracker --profile ${AWS_PROFILE:-default}",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app fitness-tracker --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app fitness-tracker --step deploy --profile ${AWS_PROFILE:-default}",
"pre-push": "npx tsx migration/pre-push.ts",
"post-generate": "npx tsx migration/post-generate.ts",
Expand Down
2 changes: 1 addition & 1 deletion amplify-migration-apps/imported-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:shared-data": "true",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app imported-resources --profile ${AWS_PROFILE:-default}",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app imported-resources --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app imported-resources --step deploy --profile ${AWS_PROFILE:-default}",
"pre-push": "true",
"post-generate": "npx tsx migration/post-generate.ts",
Expand Down
2 changes: 1 addition & 1 deletion amplify-migration-apps/media-vault/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:shared-data": "true",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app media-vault --profile ${AWS_PROFILE:-default}",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app media-vault --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app media-vault --step deploy --profile ${AWS_PROFILE:-default}",
"pre-push": "npx tsx migration/pre-push.ts",
"post-generate": "npx tsx migration/post-generate.ts",
Expand Down
2 changes: 1 addition & 1 deletion amplify-migration-apps/mood-board/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:shared-data": "true",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app mood-board --profile ${AWS_PROFILE:-default}",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app mood-board --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app mood-board --step deploy --profile ${AWS_PROFILE:-default}",
"pre-push": "true",
"post-generate": "npx tsx migration/post-generate.ts",
Expand Down
2 changes: 1 addition & 1 deletion amplify-migration-apps/product-catalog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:shared-data": "true",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app product-catalog --profile ${AWS_PROFILE:-default}",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app product-catalog --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app product-catalog --step deploy --profile ${AWS_PROFILE:-default}",
"pre-push": "npx tsx migration/pre-push.ts",
"post-generate": "npx tsx migration/post-generate.ts",
Expand Down
2 changes: 1 addition & 1 deletion amplify-migration-apps/project-boards/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:shared-data": "true",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app project-boards --profile ${AWS_PROFILE:-default}",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app project-boards --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app project-boards --step deploy --profile ${AWS_PROFILE:-default}",
"pre-push": "true",
"post-generate": "npx tsx migration/post-generate.ts",
Expand Down
2 changes: 1 addition & 1 deletion amplify-migration-apps/store-locator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:gen1": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-src/amplifyconfiguration.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:gen2": "APP_CONFIG_PATH=${APP_CONFIG_PATH:-amplify_outputs.json} NODE_OPTIONS='--experimental-vm-modules' jest --verbose",
"test:shared-data": "true",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app store-locator --profile ${AWS_PROFILE:-default}",
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app store-locator --profile ${AWS_PROFILE:-default} ${TEARDOWN:+--teardown}",
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app store-locator --step deploy --profile ${AWS_PROFILE:-default}",
"pre-push": "npx tsx migration/pre-push.ts",
"post-generate": "npx tsx migration/post-generate.ts",
Expand Down
128 changes: 128 additions & 0 deletions codebuild_specs/gen2_migration_pr_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Gen2 Migration PR Workflow
#
# This workflow executes the full migration E2E test for apps in amplify-migration-apps.
#
# Each migration test takes approximately 30 minutes and runs in parallel.
# The workflow first builds the CLI binaries, then runs migration tests concurrently.
#
# To trigger this workflow, configure a CodeBuild project with:
# - Buildspec: codebuild_specs/gen2_migration_pr_workflow.yml
# - Environment variables: TEST_ACCOUNT_ROLE (IAM role ARN for test account)
#
version: 0.2
env:
shell: bash
compute-type: BUILD_GENERAL1_MEDIUM
variables:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
CDK_DEFAULT_REGION: us-east-1
CLI_REGION: us-east-1
AMPLIFY_DIR: '$CODEBUILD_SRC_DIR/out'
AMPLIFY_PATH: '$CODEBUILD_SRC_DIR/out/amplify-pkg-linux-x64'

batch:
fast-fail: false
build-graph:
# Build phase - required for all migration tests
- identifier: build_linux
buildspec: codebuild_specs/build_linux.yml
env:
compute-type: BUILD_GENERAL1_LARGE

- identifier: publish_to_local_registry
buildspec: codebuild_specs/publish_to_local_registry.yml
depend-on:
- build_linux
env:
compute-type: BUILD_GENERAL1_LARGE

- identifier: build_pkg_binaries_linux
buildspec: codebuild_specs/build_pkg_binaries_linux.yml
depend-on:
- publish_to_local_registry
env:
compute-type: BUILD_GENERAL1_LARGE

- identifier: upb
buildspec: codebuild_specs/upload_pkg_binaries_linux_only.yml
depend-on:
- build_pkg_binaries_linux
env:
compute-type: BUILD_GENERAL1_LARGE

# Migration E2E tests - run in parallel after binaries are ready
# Each test takes ~30 minutes and deploys real AWS resources
- identifier: migrate_backend_only
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
MIGRATION_APP: backend-only
depend-on:
- upb

- identifier: migrate_discussions
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
MIGRATION_APP: discussions
depend-on:
- upb

- identifier: migrate_fitness_tracker
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
MIGRATION_APP: fitness-tracker
depend-on:
- upb

# TODO: migrate_imported_resources is excluded - not ready for CI yet

- identifier: migrate_media_vault
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
MIGRATION_APP: media-vault
depend-on:
- upb

- identifier: migrate_mood_board
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
MIGRATION_APP: mood-board
depend-on:
- upb

- identifier: migrate_product_catalog
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
MIGRATION_APP: product-catalog
depend-on:
- upb

- identifier: migrate_project_boards
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
MIGRATION_APP: project-boards
depend-on:
- upb

- identifier: migrate_store_locator
buildspec: codebuild_specs/run_gen2_migration_e2e.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
MIGRATION_APP: store-locator
depend-on:
- upb
25 changes: 25 additions & 0 deletions codebuild_specs/run_gen2_migration_e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 0.2
env:
shell: bash
variables:
CI: true
IS_AMPLIFY_CI: true
TEARDOWN: "1"

phases:
build:
commands:
- export NODE_OPTIONS=--max-old-space-size=4096
- export AMPLIFY_DIR=$CODEBUILD_SRC_DIR/out
- export AMPLIFY_PATH=$CODEBUILD_SRC_DIR/out/amplify-pkg-linux-x64
- echo "AMPLIFY_DIR=$AMPLIFY_DIR"
- echo "AMPLIFY_PATH=$AMPLIFY_PATH"
- echo "MIGRATION_APP=$MIGRATION_APP"
- source ./shared-scripts.sh && _runGen2MigrationE2E

post_build:
commands:
- echo "Migration E2E test completed for $MIGRATION_APP"

# 45 minute timeout to accommodate ~30 min migration + buffer
# This is set at the CodeBuild project level, but documented here for reference
11 changes: 11 additions & 0 deletions codebuild_specs/upload_pkg_binaries_linux_only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 0.2
env:
shell: bash
phases:
build:
commands:
- source ./shared-scripts.sh && _uploadPkgBinariesLinuxOnly

artifacts:
files:
- 'shared-scripts.sh'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"cloud-e2e-beta": "bash -c 'source ./scripts/cloud-e2e.sh && cloudE2EBeta'",
"cloud-e2e-local": "bash -c 'source ./scripts/cloud-e2e.sh && cloudE2ELocal'",
"cloud-e2e": "bash -c 'source ./scripts/cloud-e2e.sh && cloudE2E'",
"cloud-gen2-migration": "bash -c 'source ./scripts/cloud-gen2-migration.sh && cloudGen2Migration'",
"cloud-pr": "./scripts/cloud-pr.sh",
"commit": "git-cz",
"coverage:collect": "ts-node ./scripts/collect-test-coverage.ts",
Expand Down
1 change: 0 additions & 1 deletion packages/amplify-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"@aws-amplify/amplify-util-import": "2.8.6",
"@aws-amplify/amplify-util-mock": "5.10.26",
"@aws-amplify/amplify-util-uibuilder": "1.14.25",
"@aws-amplify/backend-data": "^1.6.2",
"@aws-amplify/plugin-types": "^1.11.1",
"@aws-cdk/cloudformation-diff": "~2.68.0",
"@aws-sdk/client-amplify": "^3.919.0",
Expand Down
24 changes: 18 additions & 6 deletions packages/amplify-gen2-migration-e2e-system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,32 @@ Automation system for end-to-end testing of the Amplify Gen1-to-Gen2 migration w
# Set AMPLIFY_PATH to your development Amplify CLI (optional - falls back to monorepo build, then global install)
export AMPLIFY_PATH=$(pwd)/.bin/amplify-dev

# Migrate an app using a named AWS profile
# Local dev: migrate an app using a named AWS profile
npx tsx src/cli.ts --app project-boards --profile default

# CI: migrate using an IAM role that gets re-assumed before each long step
npx tsx src/cli.ts --app project-boards --roleArn arn:aws:iam::123456789012:role/TestRole

# Verbose logging
npx tsx src/cli.ts --app project-boards --profile default --verbose
```

### CLI Options

| Option | Alias | Description |
| ----------- | ----- | ---------------------------------------------------------------------------------- |
| `--app` | `-a` | App to migrate (required). Must match a directory under `amplify-migration-apps/`. |
| `--profile` | | AWS profile to use (required). |
| `--verbose` | `-v` | Enable debug-level logging. |
| Option | Alias | Description |
| ------------ | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--app` | `-a` | App to migrate (required). Must match a directory under `amplify-migration-apps/`. |
| `--profile` | | AWS profile to use. Mutually exclusive with `--roleArn`. |
| `--roleArn` | | IAM role ARN to re-assume before each long-running step. Defaults to `TEST_ACCOUNT_ROLE` env var. Mutually exclusive with `--profile`. |
| `--verbose` | `-v` | Enable debug-level logging. |
| `--step` | | Stop at a specific step (`deploy` or `migrate`). Defaults to `migrate`. |
| `--teardown` | | Delete all deployed resources after execution. |

Exactly one credential source must be supplied. Resolution order: `--roleArn` flag, `--profile` flag, `TEST_ACCOUNT_ROLE` env var. `AWS_PROFILE` is intentionally not a fallback — pass `--profile` explicitly for local dev.

### Credential Refresh

Full migration runs take 30+ minutes, which exceeds typical STS session TTLs. When `--roleArn` is used, the CLI re-assumes the role and rewrites `~/.aws/credentials` before every long-running step (`init`, `push`, `assess`, `lock`, `generate`, `refactor`, `deployGen2Sandbox`, `teardown`) so sessions don't expire mid-operation. Spawned subprocesses (Amplify CLI, `ampx sandbox`) pick up the refreshed profile via `AWS_PROFILE`. In `--profile` mode, no refresh happens — the caller-supplied profile is assumed to be long-lived.

## Migration Workflow

Expand Down
2 changes: 2 additions & 0 deletions packages/amplify-gen2-migration-e2e-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"@aws-amplify/amplify-e2e-core": "workspace:^",
"@aws-sdk/client-amplify": "^3.919.0",
"@aws-sdk/client-cloudformation": "^3.919.0",
"@aws-sdk/client-s3": "^3.919.0",
"@aws-sdk/client-sts": "^3.919.0",
"@paralleldrive/cuid2": "^3.0.6",
"chalk": "^4.1.2",
"execa": "^5.1.1",
Expand Down
Loading
Loading