From 3a5bee5167d62a320f50489e876bcb2bd0a9a27d Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 8 May 2021 10:40:27 -0700 Subject: [PATCH] fix: function e2e tests --- .../service-walkthroughs/lambda-walkthrough.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/amplify-category-function/src/provider-utils/awscloudformation/service-walkthroughs/lambda-walkthrough.ts b/packages/amplify-category-function/src/provider-utils/awscloudformation/service-walkthroughs/lambda-walkthrough.ts index 5f1272c1390..22fec12b8bd 100644 --- a/packages/amplify-category-function/src/provider-utils/awscloudformation/service-walkthroughs/lambda-walkthrough.ts +++ b/packages/amplify-category-function/src/provider-utils/awscloudformation/service-walkthroughs/lambda-walkthrough.ts @@ -197,9 +197,6 @@ export async function updateWalkthrough(context, lambdaToUpdate?: string) { merge(functionParameters, additionalParameters); updateCFNFileForResourcePermissions(resourceDirPath, functionParameters, currentParameters); - } else { - // Need to load previous dependsOn - functionParameters.dependsOn = _.get(context.amplify.getProjectMeta(), ['function', lambdaToUpdate, 'dependsOn'], []); } // ask scheduling Lambda questions and merge in results @@ -353,7 +350,7 @@ export function updateCFNFileForResourcePermissions( apiResourceName, ); - if (cfnContent.Resources.AmplifyResourcesPolicy > 0) { + if (!cfnContent.Resources.AmplifyResourcesPolicy) { cfnContent.Resources.AmplifyResourcesPolicy = { DependsOn: ['LambdaExecutionRole'], Type: 'AWS::IAM::Policy', @@ -366,12 +363,15 @@ export function updateCFNFileForResourcePermissions( ], PolicyDocument: { Version: '2012-10-17', - Statement: functionParameters.categoryPolicies, + Statement: [], }, }, }; - } else { + } + if (functionParameters.categoryPolicies.length === 0) { delete cfnContent.Resources.AmplifyResourcesPolicy; + } else { + cfnContent.Resources.AmplifyResourcesPolicy.Properties.PolicyDocument.Statement = functionParameters.categoryPolicies; } cfnContent.Resources.LambdaFunction.Properties.Environment.Variables = getNewCFNEnvVariables(