Skip to content

Commit e12d157

Browse files
authored
Merge pull request #157 from Enase/fix-per-function-role
Tests for - fix the case of per-function custom Role
2 parents dd1dbba + cdff2ce commit e12d157

File tree

3 files changed

+463
-2
lines changed

3 files changed

+463
-2
lines changed

lib/stackops/lambdaRole.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ module.exports = function(currentTemplate, aliasStackTemplates, currentAliasStac
3535
const role = stageStack.Resources.IamRoleLambdaExecution;
3636

3737
// Set role name
38-
_.last(role.Properties.RoleName['Fn::Join']).push(this._alias);
38+
if (role.Properties.RoleName['Fn::Join']) {
39+
_.last(role.Properties.RoleName['Fn::Join']).push(this._alias);
40+
}
3941

4042
stageStack.Resources[roleLogicalId] = stageStack.Resources.IamRoleLambdaExecution;
4143
delete stageStack.Resources.IamRoleLambdaExecution;
4244

4345
// Replace references
4446
const functions = _.filter(stageStack.Resources, ['Type', 'AWS::Lambda::Function']);
45-
_.forEach(functions, func => {
47+
48+
const functionsWithIamRoleReference = _.filter(functions, (func) => _.isEqual(
49+
func.Properties.Role,
50+
{'Fn::GetAtt': ['IamRoleLambdaExecution', 'Arn' ]}
51+
));
52+
53+
_.forEach(functionsWithIamRoleReference, func => {
4654
func.Properties.Role = {
4755
'Fn::GetAtt': [
4856
roleLogicalId,

0 commit comments

Comments
 (0)