Skip to content

Commit cdff2ce

Browse files
author
Sergii Kovalev
committed
CR Changes: fix the case of per-function custom Role
1 parent 43484a9 commit cdff2ce

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

lib/stackops/lambdaRole.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,21 @@ module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStac
4444

4545
// Replace references
4646
const functions = _.filter(stageStack.Resources, ['Type', 'AWS::Lambda::Function']);
47-
_.forEach(functions, func => {
48-
if (_.isEqual(func.Properties.Role, { 'Fn::GetAtt': ['IamRoleLambdaExecution', 'Arn' ]})) {
49-
func.Properties.Role = {
50-
'Fn::GetAtt': [
51-
roleLogicalId,
52-
'Arn'
53-
]
54-
};
55-
const dependencyIndex = _.indexOf(func.DependsOn, 'IamRoleLambdaExecution');
56-
func.DependsOn[dependencyIndex] = roleLogicalId;
57-
}
47+
48+
const functionsWithIamRoleReference = _.filter(functions, (func) => _.isEqual(
49+
func.Properties.Role,
50+
{'Fn::GetAtt': ['IamRoleLambdaExecution', 'Arn' ]}
51+
));
52+
53+
_.forEach(functionsWithIamRoleReference, func => {
54+
func.Properties.Role = {
55+
'Fn::GetAtt': [
56+
roleLogicalId,
57+
'Arn'
58+
]
59+
};
60+
const dependencyIndex = _.indexOf(func.DependsOn, 'IamRoleLambdaExecution');
61+
func.DependsOn[dependencyIndex] = roleLogicalId;
5862
});
5963

6064
if (_.has(currentTemplate, 'Resources.IamRoleLambdaExecution')) {

0 commit comments

Comments
 (0)