Skip to content

Commit

Permalink
fix: function e2e tests (#7295)
Browse files Browse the repository at this point in the history
Fixes function e2e test bugs
  • Loading branch information
akshbhu authored May 8, 2021
1 parent 673aaa7 commit 5c918be
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand All @@ -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(
Expand Down

0 comments on commit 5c918be

Please sign in to comment.