Skip to content

Commit 9203c1f

Browse files
author
Nobuo Sakiyama
committed
fix the case of per-function custom Role
1 parent 6b9d0ac commit 9203c1f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/stackops/lambdaRole.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStac
4343
// Replace references
4444
const functions = _.filter(stageStack.Resources, ['Type', 'AWS::Lambda::Function']);
4545
_.forEach(functions, func => {
46-
func.Properties.Role = {
47-
'Fn::GetAtt': [
48-
roleLogicalId,
49-
'Arn'
50-
]
51-
};
52-
const dependencyIndex = _.indexOf(func.DependsOn, 'IamRoleLambdaExecution');
53-
func.DependsOn[dependencyIndex] = roleLogicalId;
46+
if (_.isEqual(func.Properties.Role, { 'Fn::GetAtt': ['IamRoleLambdaExecution', 'Arn' ]})) {
47+
func.Properties.Role = {
48+
'Fn::GetAtt': [
49+
roleLogicalId,
50+
'Arn'
51+
]
52+
};
53+
const dependencyIndex = _.indexOf(func.DependsOn, 'IamRoleLambdaExecution');
54+
func.DependsOn[dependencyIndex] = roleLogicalId;
55+
}
5456
});
5557

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

0 commit comments

Comments
 (0)