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 {