Skip to content

Commit

Permalink
fix: remove managed policies from cloned role
Browse files Browse the repository at this point in the history
  • Loading branch information
jogold committed May 28, 2018
1 parent 8d601b4 commit 942816f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ class ServerlessIamPerFunctionPlugin {
},
],
};
// remove managed policies
functionIamRole.Properties.ManagedPolicyArns = [];
//set vpc if needed
if (!_.isEmpty(functionObject.vpc) || !_.isEmpty(this.serverless.service.provider.vpc)) {
functionIamRole.Properties.ManagedPolicyArns = [
Expand Down
1 change: 1 addition & 0 deletions src/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ describe('plugin tests', function(this: any) {
const helloRole = serverless.service.provider.compiledCloudFormationTemplate.Resources.HelloIamRoleLambdaExecution;
assert.isNotEmpty(helloRole);
assertFunctionRoleName('hello', helloRole.Properties.RoleName);
assert.isEmpty(helloRole.Properties.ManagedPolicyArns, 'function resource role has no managed policy');
//check depends and role is set properlly
const helloFunctionResource = serverless.service.provider.compiledCloudFormationTemplate.Resources.HelloLambdaFunction;
assert.isTrue(helloFunctionResource.DependsOn.indexOf('HelloIamRoleLambdaExecution') >= 0, 'function resource depends on role');
Expand Down

0 comments on commit 942816f

Please sign in to comment.