Skip to content

Commit

Permalink
Merge 9405371 into 6b9d0ac
Browse files Browse the repository at this point in the history
  • Loading branch information
Enase committed Apr 23, 2019
2 parents 6b9d0ac + 9405371 commit c844ac0
Show file tree
Hide file tree
Showing 4 changed files with 467 additions and 11 deletions.
22 changes: 13 additions & 9 deletions lib/stackops/lambdaRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,26 @@ module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStac
const role = stageStack.Resources.IamRoleLambdaExecution;

// Set role name
_.last(role.Properties.RoleName['Fn::Join']).push(this._alias);
if (role.Properties.RoleName['Fn::Join']) {
_.last(role.Properties.RoleName['Fn::Join']).push(this._alias);
}

stageStack.Resources[roleLogicalId] = stageStack.Resources.IamRoleLambdaExecution;
delete stageStack.Resources.IamRoleLambdaExecution;

// Replace references
const functions = _.filter(stageStack.Resources, ['Type', 'AWS::Lambda::Function']);
_.forEach(functions, func => {
func.Properties.Role = {
'Fn::GetAtt': [
roleLogicalId,
'Arn'
]
};
const dependencyIndex = _.indexOf(func.DependsOn, 'IamRoleLambdaExecution');
func.DependsOn[dependencyIndex] = roleLogicalId;
if (_.isEqual(func.Properties.Role, { 'Fn::GetAtt': ['IamRoleLambdaExecution', 'Arn' ]})) {
func.Properties.Role = {
'Fn::GetAtt': [
roleLogicalId,
'Arn'
]
};
const dependencyIndex = _.indexOf(func.DependsOn, 'IamRoleLambdaExecution');
func.DependsOn[dependencyIndex] = roleLogicalId;
}
});

if (_.has(currentTemplate, 'Resources.IamRoleLambdaExecution')) {
Expand Down
Loading

0 comments on commit c844ac0

Please sign in to comment.