Skip to content

Commit c1723d5

Browse files
authored
Merge pull request #148 from ACSchott526/pseudo-params
Allow pseudo-parameters in function arn regex
2 parents 3c6b37c + 2afbe6f commit c1723d5

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/deploy/stepFunctions/compileIamRole.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
customRolesProvided.push('role' in stateMachineObj);
1313

1414
const stateMachineJson = JSON.stringify(stateMachineObj);
15-
const regex = new RegExp(/"Resource":"([\w\-:*]*)"/gi);
15+
const regex = new RegExp(/"Resource":"([\w\-:*#{}.]*)"/gi);
1616
let match = regex.exec(stateMachineJson);
1717
while (match !== null) {
1818
functionArns.push(match[1]);

lib/deploy/stepFunctions/compileIamRole.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ describe('#compileIamRole', () => {
9090
const helloLambda = 'arn:aws:lambda:123:*:function:hello';
9191
const worldLambda = 'arn:aws:lambda:*:*:function:world';
9292
const fooLambda = 'arn:aws:lambda:us-west-2::function:foo_';
93+
const barLambda = 'arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:bar';
9394
serverless.service.stepFunctions = {
9495
stateMachines: {
9596
myStateMachine1: {
@@ -131,6 +132,19 @@ describe('#compileIamRole', () => {
131132
},
132133
},
133134
},
135+
myStateMachine4: {
136+
name: 'stateMachineBeta4',
137+
definition: {
138+
StartAt: 'Bar',
139+
States: {
140+
Hello: {
141+
Type: 'Task',
142+
Resource: barLambda,
143+
End: true,
144+
},
145+
},
146+
},
147+
},
134148
},
135149
};
136150

@@ -139,6 +153,6 @@ describe('#compileIamRole', () => {
139153
.provider.compiledCloudFormationTemplate.Resources.IamRoleStateMachineExecution
140154
.Properties.Policies[0];
141155
expect(policy.PolicyDocument.Statement[0].Resource)
142-
.to.be.deep.equal([helloLambda, worldLambda, fooLambda]);
156+
.to.be.deep.equal([helloLambda, worldLambda, fooLambda, barLambda]);
143157
});
144158
});

0 commit comments

Comments
 (0)