From b1ca1b1efe70425b97c9083f5ac47d71c32aaeb7 Mon Sep 17 00:00:00 2001 From: rjabhi Date: Wed, 18 Dec 2024 13:37:58 -0800 Subject: [PATCH] fix: add uncomment instructions in readme --- .../src/backend/synthesizer.ts | 1 - .../src/migration-readme-generator.test.ts | 14 +++++++++++++- .../src/migration-readme-generator.ts | 14 +++++++++++++- packages/amplify-migration/src/command-handlers.ts | 9 +++++++-- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/packages/amplify-gen2-codegen/src/backend/synthesizer.ts b/packages/amplify-gen2-codegen/src/backend/synthesizer.ts index 6f9e43ce28..654111200d 100644 --- a/packages/amplify-gen2-codegen/src/backend/synthesizer.ts +++ b/packages/amplify-gen2-codegen/src/backend/synthesizer.ts @@ -6,7 +6,6 @@ import ts, { ImportDeclaration, Node, NodeArray, - SyntaxKind, VariableDeclaration, VariableStatement, } from 'typescript'; diff --git a/packages/amplify-migration-template-gen/src/migration-readme-generator.test.ts b/packages/amplify-migration-template-gen/src/migration-readme-generator.test.ts index ed340d7099..d5f366925c 100644 --- a/packages/amplify-migration-template-gen/src/migration-readme-generator.test.ts +++ b/packages/amplify-migration-template-gen/src/migration-readme-generator.test.ts @@ -122,11 +122,23 @@ Describe stack refactor to check for execution status `### STEP 2: REDEPLOY GEN2 APPLICATION This step will remove the hardcoded references from the template and replace them with resource references (where applicable). -2.a) Only applicable to Storage category: Uncomment the following line in \`amplify/backend.ts\` file to instruct CDK to use the gen1 S3 bucket +2.a) Uncomment the following lines in \`amplify/backend.ts\` file to instruct CDK to use the gen1 S3 bucket (if storage is enabled) and apply retain removal policies for auth and/or storage resources \`\`\` s3Bucket.bucketName = YOUR_GEN1_BUCKET_NAME; \`\`\` +\`\`\` +s3Bucket.applyRemovalPolicy(RemovalPolicy.RETAIN, { applyToUpdateReplacePolicy: true }); +\`\`\` + +\`\`\` +cfnUserPool.applyRemovalPolicy(RemovalPolicy.RETAIN, { applyToUpdateReplacePolicy: true }); +\`\`\` + +\`\`\` +cfnIdentityPool.applyRemovalPolicy(RemovalPolicy.RETAIN, { applyToUpdateReplacePolicy: true }); +\`\`\` + 2.b) Deploy sandbox using the below command or trigger a CI/CD build via hosting by committing this file to your Git repository \`\`\` npx ampx sandbox diff --git a/packages/amplify-migration-template-gen/src/migration-readme-generator.ts b/packages/amplify-migration-template-gen/src/migration-readme-generator.ts index 6d2ebe7706..d4ede7765e 100644 --- a/packages/amplify-migration-template-gen/src/migration-readme-generator.ts +++ b/packages/amplify-migration-template-gen/src/migration-readme-generator.ts @@ -152,11 +152,23 @@ Describe stack refactor to check for execution status `### STEP 2: REDEPLOY GEN2 APPLICATION This step will remove the hardcoded references from the template and replace them with resource references (where applicable). -2.a) Only applicable to Storage category: Uncomment the following line in \`amplify/backend.ts\` file to instruct CDK to use the gen1 S3 bucket +2.a) Uncomment the following lines in \`amplify/backend.ts\` file to instruct CDK to use the gen1 S3 bucket (if storage is enabled) and apply retain removal policies for auth and/or storage resources \`\`\` s3Bucket.bucketName = YOUR_GEN1_BUCKET_NAME; \`\`\` +\`\`\` +s3Bucket.applyRemovalPolicy(RemovalPolicy.RETAIN, { applyToUpdateReplacePolicy: true }); +\`\`\` + +\`\`\` +cfnUserPool.applyRemovalPolicy(RemovalPolicy.RETAIN, { applyToUpdateReplacePolicy: true }); +\`\`\` + +\`\`\` +cfnIdentityPool.applyRemovalPolicy(RemovalPolicy.RETAIN, { applyToUpdateReplacePolicy: true }); +\`\`\` + 2.b) Deploy sandbox using the below command or trigger a CI/CD build via hosting by committing this file to your Git repository \`\`\` npx ampx sandbox diff --git a/packages/amplify-migration/src/command-handlers.ts b/packages/amplify-migration/src/command-handlers.ts index 6d7dd9eb1a..342d560108 100644 --- a/packages/amplify-migration/src/command-handlers.ts +++ b/packages/amplify-migration/src/command-handlers.ts @@ -158,6 +158,7 @@ const resolveAppId = (): string => { const unsupportedCategories = (): Map => { const unsupportedCategories = new Map(); const urlPrefix = 'https://docs.amplify.aws/react/build-a-backend/add-aws-services'; + const restAPIKey = 'rest api'; unsupportedCategories.set('geo', `${urlPrefix}/geo/`); unsupportedCategories.set('analytics', `${urlPrefix}/analytics/`); @@ -179,13 +180,17 @@ const unsupportedCategories = (): Map => { Object.keys(apiList).forEach((api) => { const apiObj = apiList[api]; if (apiObj.service == 'API Gateway') { - unsupportedCategoriesList.set('rest api', unsupportedCategories.get('rest api')!); + const restAPIDocsLink = unsupportedCategories.get(restAPIKey); + assert(restAPIDocsLink); + unsupportedCategoriesList.set(restAPIKey, restAPIDocsLink); } }); } } else { if (unsupportedCategories.has(category) && Object.entries(meta[category]).length > 0) { - unsupportedCategoriesList.set(category, unsupportedCategories.get(category)!); + const unsupportedCategoryDocLink = unsupportedCategories.get(category); + assert(unsupportedCategoryDocLink); + unsupportedCategoriesList.set(category, unsupportedCategoryDocLink); } } });