Skip to content

Commit b0a0e5c

Browse files
authored
Merge pull request #154 from ACSchott526/function-regex
Add dollar sign to function arn regex
2 parents 5f00a63 + f3b7354 commit b0a0e5c

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
@@ -91,6 +91,7 @@ describe('#compileIamRole', () => {
9191
const worldLambda = 'arn:aws:lambda:*:*:function:world';
9292
const fooLambda = 'arn:aws:lambda:us-west-2::function:foo_';
9393
const barLambda = 'arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:bar';
94+
const bazLambda = 'arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${baz}';
9495
serverless.service.stepFunctions = {
9596
stateMachines: {
9697
myStateMachine1: {
@@ -145,6 +146,19 @@ describe('#compileIamRole', () => {
145146
},
146147
},
147148
},
149+
myStateMachine5: {
150+
name: 'stateMachineBeta5',
151+
definition: {
152+
StartAt: 'Baz',
153+
States: {
154+
Hello: {
155+
Type: 'Task',
156+
Resource: bazLambda,
157+
End: true,
158+
},
159+
},
160+
},
161+
},
148162
},
149163
};
150164

@@ -153,6 +167,6 @@ describe('#compileIamRole', () => {
153167
.provider.compiledCloudFormationTemplate.Resources.IamRoleStateMachineExecution
154168
.Properties.Policies[0];
155169
expect(policy.PolicyDocument.Statement[0].Resource)
156-
.to.be.deep.equal([helloLambda, worldLambda, fooLambda, barLambda]);
170+
.to.be.deep.equal([helloLambda, worldLambda, fooLambda, barLambda, bazLambda]);
157171
});
158172
});

0 commit comments

Comments
 (0)