Skip to content

Commit 6597ea0

Browse files
authored
chore(gen2-migration): stable & e2e based snapshots (#14782)
* feat(amplify-gen2-migration-e2e-system): add snapshot normalization Add a normalize script that replaces run-specific values (deploymentName, envName, envHash, sandboxHash, commitHash, CFN nested stack hashes) with stable placeholders in snapshot filenames and content, making snapshots deterministic across e2e runs. Use a fixed --identifier e2e for ampx sandbox deployments instead of deriving the stack prefix from os.userInfo().username. Regenerate and normalize project-boards snapshots. --- Prompt: commit everything * chore: reset project-boards snapshots * chore: regen project-boards snapshots with e2e * chore: normalization script to project-boards * chore: mid work * chore: new snapshots take 1 * chore: normalize snapshots after e2e run * chore: snapshots again * chore: normalize skip replaced hashes * chore: more snapshots * chore: fixed length replacement * chore: new snapshots * chore: new snapshots * chore: new snapshots * chore: sanitize all outputs * chore: sanitize all outputs * chore: sanitize based on outputs * chore: restore snapshots * chore: restore snapshots * chore: restore snapshots * chore: restore snapshots * snapshots * snapshots * snapshots * snapshots * chore: mid work * chore: more snapshots * chore: regen project-boards pre.generate * chore: fix scripts * chore: restore gen2-migration snapshots * chore: regen project-boards snapshots * chore: regen project-boards snapshots * chore: regen discussions snapshots * chore: regen project-boards snapshots * chore: restore gen2-migration fitness-tracker snapshots * chore: restore gen2-migration product-catalog snapshots * chore: regen discussions snapshots * chore: restore gen2-migration store-locator snapshots * chore: restore gen2-migration media-vault snapshots * chore: restore gen2-migration backend-only snapshots * chore: restore gen2-migration mood-board snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * refactor(amplify-gen2-migration-e2e-system): clean up sanitize and normalize, update docs Remove getAllFiles wrapper, unused os import, and username sanitization from sanitize.ts. Fix orphaned JSDoc in normalize.ts. Update sanitize JSDoc to reflect current behavior. Add snapshot post-processing documentation to the E2E system README covering normalization and sanitization steps. Slim down the migration-apps README to point to the E2E README for details while keeping the manual invocation instructions local. --- Prompt: commit * chore: update yarn.lock * chore: restore gen2-migration snapshot * chore: restore gen2-migration snapshot * refactor(amplify-gen2-migration-e2e-system): remove output value replacements, restore gen2 API key sanitization Remove the output value replacement logic from sanitize.ts — it was replacing values inside pre.generate snapshots that the generate command depends on. Restore the original gen2 API key extraction and sanitization. Normalize now only renames files, no content replacement. --- Prompt: commit * fix(amplify-gen2-migration-e2e-system): remove da2- prefix guard on API key sanitization --- Prompt: made some changes, commit * chore: regen snapshots * feat: add normalize script to all apps * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: regen snapshots * chore: lock file * chore: regen snapshots
1 parent e313e27 commit 6597ea0

File tree

4,152 files changed

+200889
-199945
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,152 files changed

+200889
-199945
lines changed

amplify-migration-apps/README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,21 @@ Some refactors target a `-holding` stack (visible in the target stack name). Res
221221
moved from the Gen2 stack to the holding stack (to make room), then from the Gen1 stack to the
222222
Gen2 stack. The holding stack persists as the final destination for the Gen2 stateful resources.
223223

224-
## Sanitization
224+
## Normalization and Sanitization
225225

226-
Sensitive values must be replaced with safe placeholder values before they are committed.
227-
Each app's `package.json` includes a `sanitize` script that invokes the shared `sanitize.ts`
228-
at the root of this directory. This runs automatically on commit via the Husky pre-commit hook,
229-
so you don't need to run it manually. If you do want to run it yourself:
226+
After snapshots are captured, they must be normalized and sanitized before committing.
227+
See the [E2E system README](../packages/amplify-gen2-migration-e2e-system/README.md#snapshot-post-processing)
228+
for details on what each step does.
229+
230+
To run them manually on a single app:
230231

231232
```console
232233
cd amplify-migration-apps/<app-name>
233-
npm run sanitize
234+
npx tsx ../normalize.ts
235+
npx tsx ../sanitize.ts
234236
```
235237

236-
The script extracts values from `amplify-meta.json` and replaces them across all snapshot files:
237-
238-
| Value | Placeholder |
239-
| ---------------- | ---------------------------------- |
240-
| AWS Account ID | `123456789012` |
241-
| Amplify App ID | `<app-name-no-dashes>` |
242-
| AppSync API Key | `da2-fakeapikey00000000000000` |
238+
Order matters — normalize first, then sanitize.
243239

244240
## Typechecking
245241

amplify-migration-apps/backend-only/_snapshot.post.generate/amplify/backend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ cfnGraphqlApi.additionalAuthenticationProviders = [
4444
];
4545
const s3Bucket = backend.storage.resources.cfnResources.cfnBucket;
4646
// Use this bucket name post refactor
47-
// s3Bucket.bucketName = 'backendonlycb1a13ab81664ecaa7d015068ab2d0165e0fa-main';
47+
// s3Bucket.bucketName = 'backendonlycb1a13ab81664ecaa7d015068ab2d016x-x';
4848
s3Bucket.bucketEncryption = {
4949
serverSideEncryptionConfiguration: [
5050
{

amplify-migration-apps/backend-only/_snapshot.post.generate/amplify/data/resource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ export const data = defineData({
4949
migratedAmplifyGen1DynamoDbTableMappings: [
5050
{
5151
//The "branchname" variable needs to be the same as your deployment branch if you want to reuse your Gen1 app tables
52-
branchName: 'main',
52+
branchName: 'x',
5353
modelNameToTableNameMapping: {
54-
Project: 'Project-sgumi4ggubb4jdo6i54km7skka-main',
55-
Todo: 'Todo-sgumi4ggubb4jdo6i54km7skka-main',
54+
Project: 'Project-q2d7oghxlbgxxj3fr2t6f2bpm4-x',
55+
Todo: 'Todo-q2d7oghxlbgxxj3fr2t6f2bpm4-x',
5656
},
5757
},
5858
],

amplify-migration-apps/backend-only/_snapshot.post.generate/amplify/storage/resource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { defineStorage } from '@aws-amplify/backend';
33
const branchName = process.env.AWS_BRANCH ?? 'sandbox';
44

55
export const storage = defineStorage({
6-
name: `backendonlycb1a13ab81664ecaa7d015068ab2d0165e0fa-${branchName}`,
6+
name: `backendonlycb1a13ab81664ecaa7d015068ab2d016x-${branchName}`,
77
access: (allow) => ({
88
'public/*': [
99
allow.guest.to(['read']),

amplify-migration-apps/backend-only/_snapshot.post.generate/package.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,27 @@
77
"hoistingLimits": "workspaces"
88
},
99
"scripts": {
10+
"configure": "./backend/configure.sh",
1011
"sanitize": "tsx ../sanitize.ts",
11-
"typecheck": "cd _snapshot.post.generate/amplify && npx tsc --noEmit"
12-
},
13-
"dependencies": {
14-
"cli-table3": "0.6.5"
12+
"normalize": "tsx ../normalize.ts",
13+
"typecheck": "cd _snapshot.post.generate/amplify && npx tsc --noEmit",
14+
"test:gen1": "true",
15+
"test:gen2": "true",
16+
"test:shared-data": "true",
17+
"test:e2e": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app backend-only --profile ${AWS_PROFILE:-default}",
18+
"deploy": "cd ../../packages/amplify-gen2-migration-e2e-system && npx tsx src/cli.ts --app backend-only --step deploy --profile ${AWS_PROFILE:-default}",
19+
"pre-push": "true",
20+
"post-generate": "npx tsx migration/post-generate.ts",
21+
"post-refactor": "npx tsx migration/post-refactor.ts",
22+
"post-sandbox": "true",
23+
"pre-sandbox": "true",
24+
"post-push": "true"
1525
},
1626
"devDependencies": {
1727
"@aws-amplify/backend": "^1.18.0",
1828
"@aws-amplify/backend-cli": "^1.8.0",
1929
"@aws-amplify/backend-data": "^1.6.2",
30+
"@aws-sdk/client-cognito-identity-provider": "^3.936.0",
2031
"@types/aws-lambda": "^8.10.92",
2132
"@types/node": "*",
2233
"aws-cdk": "^2",
@@ -25,5 +36,8 @@
2536
"constructs": "^10.0.0",
2637
"esbuild": "^0.27.0",
2738
"tsx": "^4.20.6"
39+
},
40+
"dependencies": {
41+
"cli-table3": "0.6.5"
2842
}
2943
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[
2+
{
3+
"Source": {
4+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x",
5+
"LogicalResourceId": "amplifyAuthUserPool4BA7F805"
6+
},
7+
"Destination": {
8+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x-holding",
9+
"LogicalResourceId": "amplifyAuthUserPool4BA7F805"
10+
}
11+
},
12+
{
13+
"Source": {
14+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x",
15+
"LogicalResourceId": "amplifyAuthUserPoolNativeAppClient79534448"
16+
},
17+
"Destination": {
18+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x-holding",
19+
"LogicalResourceId": "amplifyAuthUserPoolNativeAppClient79534448"
20+
}
21+
},
22+
{
23+
"Source": {
24+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x",
25+
"LogicalResourceId": "amplifyAuthUserPoolAppClient2626C6F8"
26+
},
27+
"Destination": {
28+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x-holding",
29+
"LogicalResourceId": "amplifyAuthUserPoolAppClient2626C6F8"
30+
}
31+
},
32+
{
33+
"Source": {
34+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x",
35+
"LogicalResourceId": "amplifyAuthIdentityPool3FDE84CC"
36+
},
37+
"Destination": {
38+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x-holding",
39+
"LogicalResourceId": "amplifyAuthIdentityPool3FDE84CC"
40+
}
41+
},
42+
{
43+
"Source": {
44+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x",
45+
"LogicalResourceId": "amplifyAuthIdentityPoolRoleAttachment045F17C8"
46+
},
47+
"Destination": {
48+
"StackName": "amplify-backendonly-e2e-sandbox-x-auth179371D7-x-holding",
49+
"LogicalResourceId": "amplifyAuthIdentityPoolRoleAttachment045F17C8"
50+
}
51+
}
52+
]

0 commit comments

Comments
 (0)