From fedb6c49cf0695e21f59929e7d0554b59290f2f1 Mon Sep 17 00:00:00 2001 From: akshbhu <39866697+akshbhu@users.noreply.github.com> Date: Wed, 5 May 2021 11:41:13 -0700 Subject: [PATCH] fix: e2e failed tests for auth Triggers PR (#7262) * fix: e2e failed tests for auth Triggers PR * fix: update lambda nodejs runtime --- .../utils/generate-auth-trigger-template.ts | 2 +- .../src/utils/upload-auth-trigger-template.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/generate-auth-trigger-template.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/generate-auth-trigger-template.ts index fa47a3215e7..7139b06d0be 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/generate-auth-trigger-template.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/utils/generate-auth-trigger-template.ts @@ -87,7 +87,7 @@ async function createCustomResourceforAuthTrigger(context: any, authTriggerConne function createCustomResource(stack: cdk.Stack, authTriggerConnections: AuthTriggerConnection[], userpoolId: cdk.CfnParameter) { const triggerCode = fs.readFileSync(authTriggerAssetFilePath, 'utf-8'); const authTriggerFn = new lambda.Function(stack, 'authTriggerFn', { - runtime: lambda.Runtime.NODEJS_10_X, + runtime: lambda.Runtime.NODEJS_12_X, code: lambda.Code.fromInline(triggerCode), handler: 'index.handler', }); diff --git a/packages/amplify-provider-awscloudformation/src/utils/upload-auth-trigger-template.ts b/packages/amplify-provider-awscloudformation/src/utils/upload-auth-trigger-template.ts index 58aa31fdc7e..6ab1947fc38 100644 --- a/packages/amplify-provider-awscloudformation/src/utils/upload-auth-trigger-template.ts +++ b/packages/amplify-provider-awscloudformation/src/utils/upload-auth-trigger-template.ts @@ -14,7 +14,11 @@ export async function uploadAuthTriggerTemplate(context: $TSContext) { const category = 'auth'; let { amplifyMeta } = context.amplify.getProjectDetails(); const authResource = amplifyMeta?.auth ?? {}; - const resourceDir = path.join(pathManager.getBackendDirPath(), category, Object.keys(authResource)[0]); + const authResourceParams = Object.keys(authResource); + if (authResourceParams.length === 0) { + return {}; + } + const resourceDir = path.join(pathManager.getBackendDirPath(), category, authResourceParams[0]); const authTriggerCfnFilePath = path.join(resourceDir, AUTH_TRIGGER_TEMPLATE); const { DeploymentBucketName } = context.amplify.getProjectMeta()?.providers?.[ProviderName] ?? {}; try {