From 602818b6abe8590c03e339b55c505d0c79a70758 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 2 Nov 2023 14:04:52 -0700 Subject: [PATCH 1/3] fix: bundle latest SDK in branch linker lambda --- .eslint_dictionary.json | 1 + .../branch-linker/branch_linker_construct.ts | 7 ++++ ...ify-testAppId-testBranchName.template.json | 2 +- .../src/test-e2e/deployment.test.ts | 36 +++++++++---------- ...ify-testAppId-testBranchName.template.json | 4 +-- ...ranchNameauth8722F3FC.nested.template.json | 12 +++---- ...ify-testAppId-testBranchName.template.json | 2 +- 7 files changed, 35 insertions(+), 29 deletions(-) diff --git a/.eslint_dictionary.json b/.eslint_dictionary.json index 2812b452ed..2bfe34f6c9 100644 --- a/.eslint_dictionary.json +++ b/.eslint_dictionary.json @@ -6,6 +6,7 @@ "appsync", "argv", "arns", + "bundler", "cdk", "changelog", "changeset", diff --git a/packages/backend/src/engine/branch-linker/branch_linker_construct.ts b/packages/backend/src/engine/branch-linker/branch_linker_construct.ts index 7e308bd7f3..b71b4e2984 100644 --- a/packages/backend/src/engine/branch-linker/branch_linker_construct.ts +++ b/packages/backend/src/engine/branch-linker/branch_linker_construct.ts @@ -35,6 +35,13 @@ export class AmplifyBranchLinkerConstruct extends Construct { timeout: Duration.seconds(10), entry: linkerLambdaFilePath, handler: 'handler', + bundling: { + // TODO Remove it when Lambda serves SDK 3.440.0+ + // https://github.com/aws-amplify/samsara-cli/issues/561 + // This is added to force bundler to include local version of AWS SDK. + // Lambda provided version does not have 'backend.stackArn' yet. + externalModules: [], + }, }); linkerLambda.grantPrincipal.addToPrincipalPolicy( diff --git a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName.template.json b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName.template.json index 7a856a6dd9..4392d44bfb 100644 --- a/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName.template.json +++ b/packages/create-amplify/templates/basic-auth-data/expected-cdk-out/amplify-testAppId-testBranchName.template.json @@ -175,7 +175,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "98bdeb476c46210a30ee3b8365a50fd0d1e761f483b4908f725362ba64d23c59.zip" + "S3Key": "2194a3b7d50443cf7f4b1eeb75ed230d4beb1ce0f73ccf994e6d15317c79a378.zip" }, "Environment": { "Variables": { diff --git a/packages/integration-tests/src/test-e2e/deployment.test.ts b/packages/integration-tests/src/test-e2e/deployment.test.ts index 1f711bd7da..31ab42ea0c 100644 --- a/packages/integration-tests/src/test-e2e/deployment.test.ts +++ b/packages/integration-tests/src/test-e2e/deployment.test.ts @@ -48,25 +48,23 @@ void describe('amplify deploys', async () => { void it(`[${testProject.name}] deploys fully`, async () => { await testProject.deploy(branchBackendIdentifier); await testProject.assertPostDeployment(); - // TODO enable these assertions when stackArn round trips from service. - // https://github.com/aws-amplify/samsara-cli/issues/554 - // const testBranchDetails = await amplifyAppPool.fetchTestBranchDetails( - // testBranch - // ); - // assert.ok( - // testBranchDetails.backend?.stackArn, - // 'branch should have stack associated' - // ); - // assert.ok( - // testBranchDetails.backend?.stackArn?.includes( - // branchBackendIdentifier.backendId - // ) - // ); - // assert.ok( - // testBranchDetails.backend?.stackArn?.includes( - // branchBackendIdentifier.disambiguator - // ) - // ); + const testBranchDetails = await amplifyAppPool.fetchTestBranchDetails( + testBranch + ); + assert.ok( + testBranchDetails.backend?.stackArn, + 'branch should have stack associated' + ); + assert.ok( + testBranchDetails.backend?.stackArn?.includes( + branchBackendIdentifier.backendId + ) + ); + assert.ok( + testBranchDetails.backend?.stackArn?.includes( + branchBackendIdentifier.disambiguator + ) + ); }); }); }); diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers/expected-cdk-out/amplify-testAppId-testBranchName.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers/expected-cdk-out/amplify-testAppId-testBranchName.template.json index 11e6ca9d2d..efcfbcbbc0 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers/expected-cdk-out/amplify-testAppId-testBranchName.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers/expected-cdk-out/amplify-testAppId-testBranchName.template.json @@ -222,7 +222,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "98bdeb476c46210a30ee3b8365a50fd0d1e761f483b4908f725362ba64d23c59.zip" + "S3Key": "2194a3b7d50443cf7f4b1eeb75ed230d4beb1ce0f73ccf994e6d15317c79a378.zip" }, "Environment": { "Variables": { @@ -394,7 +394,7 @@ { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "/b1588ca380e76e80f240eed7acba3e7a58ddb8612e8b5e4e8cb698500255ca4e.json" + "/bffb1190157cfb84fe69186893f7e380119cc5b0d4680095958149d37f8dfd52.json" ] ] } diff --git a/packages/integration-tests/test-projects/data-storage-auth-with-triggers/expected-cdk-out/amplifytestAppIdtestBranchNameauth8722F3FC.nested.template.json b/packages/integration-tests/test-projects/data-storage-auth-with-triggers/expected-cdk-out/amplifytestAppIdtestBranchNameauth8722F3FC.nested.template.json index 02d0dd2b63..4bea0d4d84 100644 --- a/packages/integration-tests/test-projects/data-storage-auth-with-triggers/expected-cdk-out/amplifytestAppIdtestBranchNameauth8722F3FC.nested.template.json +++ b/packages/integration-tests/test-projects/data-storage-auth-with-triggers/expected-cdk-out/amplifytestAppIdtestBranchNameauth8722F3FC.nested.template.json @@ -205,7 +205,7 @@ "backendId": "testAppId", "branchName": "testBranchName", "secretName": "testAmazonId", - "secretLastUpdated": 1698951292560 + "secretLastUpdated": 1698959044636 }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -222,7 +222,7 @@ "backendId": "testAppId", "branchName": "testBranchName", "secretName": "testAmazonSecret", - "secretLastUpdated": 1698951292560 + "secretLastUpdated": 1698959044636 }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -239,7 +239,7 @@ "backendId": "testAppId", "branchName": "testBranchName", "secretName": "testFacebookId", - "secretLastUpdated": 1698951292560 + "secretLastUpdated": 1698959044636 }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -256,7 +256,7 @@ "backendId": "testAppId", "branchName": "testBranchName", "secretName": "testFacebookSecret", - "secretLastUpdated": 1698951292561 + "secretLastUpdated": 1698959044636 }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -273,7 +273,7 @@ "backendId": "testAppId", "branchName": "testBranchName", "secretName": "testGoogleId", - "secretLastUpdated": 1698951292561 + "secretLastUpdated": 1698959044636 }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -290,7 +290,7 @@ "backendId": "testAppId", "branchName": "testBranchName", "secretName": "testGoogleSecret", - "secretLastUpdated": 1698951292561 + "secretLastUpdated": 1698959044636 }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" diff --git a/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplify-testAppId-testBranchName.template.json b/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplify-testAppId-testBranchName.template.json index 79d5d790ea..32ad5bb463 100644 --- a/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplify-testAppId-testBranchName.template.json +++ b/packages/integration-tests/test-projects/minimalist-project-with-typescript-idioms/expected-cdk-out/amplify-testAppId-testBranchName.template.json @@ -102,7 +102,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "98bdeb476c46210a30ee3b8365a50fd0d1e761f483b4908f725362ba64d23c59.zip" + "S3Key": "2194a3b7d50443cf7f4b1eeb75ed230d4beb1ce0f73ccf994e6d15317c79a378.zip" }, "Environment": { "Variables": { From 9576cf28fd86f1d06124233906e2d1d42a10bd44 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 2 Nov 2023 14:07:55 -0700 Subject: [PATCH 2/3] fix: bundle latest SDK in branch linker lambda --- .changeset/warm-spoons-cheer.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/warm-spoons-cheer.md diff --git a/.changeset/warm-spoons-cheer.md b/.changeset/warm-spoons-cheer.md new file mode 100644 index 0000000000..c49c3e6dc5 --- /dev/null +++ b/.changeset/warm-spoons-cheer.md @@ -0,0 +1,5 @@ +--- +'@aws-amplify/backend': patch +--- + +bundle AWS SDK in branch linker lambda From 83497382150268edcdfa37cf786130c36cb75dc0 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Thu, 2 Nov 2023 14:41:08 -0700 Subject: [PATCH 3/3] grrrr --- .eslint_dictionary.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslint_dictionary.json b/.eslint_dictionary.json index 2bfe34f6c9..8853358c19 100644 --- a/.eslint_dictionary.json +++ b/.eslint_dictionary.json @@ -5,6 +5,7 @@ "appleid", "appsync", "argv", + "arn", "arns", "bundler", "cdk",