From 300d1696968705d90788a2b6393884631f29873e Mon Sep 17 00:00:00 2001 From: rjabhi Date: Wed, 11 Dec 2024 11:23:04 -0800 Subject: [PATCH] fix: add import for removal policy in gen2 codegen --- packages/amplify-gen2-codegen/src/backend/synthesizer.test.ts | 2 ++ packages/amplify-gen2-codegen/src/backend/synthesizer.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/amplify-gen2-codegen/src/backend/synthesizer.test.ts b/packages/amplify-gen2-codegen/src/backend/synthesizer.test.ts index 261942d2d1..a79a60fbff 100644 --- a/packages/amplify-gen2-codegen/src/backend/synthesizer.test.ts +++ b/packages/amplify-gen2-codegen/src/backend/synthesizer.test.ts @@ -335,6 +335,7 @@ describe('BackendRenderer', () => { }); const output = printNodeArray(rendered); assert(output.includes('s3Bucket.applyRemovalPolicy')); + assert(output.includes('import { RemovalPolicy } from "aws-cdk-lib";')); }); }); describe('UserPoolClient Configuration using render()', () => { @@ -471,6 +472,7 @@ describe('BackendRenderer', () => { const output = printNodeArray(rendered); assert(output.includes('cfnUserPool.applyRemovalPolicy')); assert(output.includes('cfnIdentityPool.applyRemovalPolicy')); + assert(output.includes('import { RemovalPolicy } from "aws-cdk-lib";')); }); }); }); diff --git a/packages/amplify-gen2-codegen/src/backend/synthesizer.ts b/packages/amplify-gen2-codegen/src/backend/synthesizer.ts index 72229bc163..c68b9c7e9b 100644 --- a/packages/amplify-gen2-codegen/src/backend/synthesizer.ts +++ b/packages/amplify-gen2-codegen/src/backend/synthesizer.ts @@ -447,6 +447,7 @@ export class BackendSynthesizer { if (renderArgs.auth) { imports.push(this.createImportStatement([authFunctionIdentifier], renderArgs.auth.importFrom)); + imports.push(this.createImportStatement([factory.createIdentifier('RemovalPolicy')], 'aws-cdk-lib')); const auth = factory.createShorthandPropertyAssignment(authFunctionIdentifier); defineBackendProperties.push(auth); }