diff --git a/lib/deploy/stepFunctions/compileIamRole.js b/lib/deploy/stepFunctions/compileIamRole.js index d2f055f0..447a8048 100644 --- a/lib/deploy/stepFunctions/compileIamRole.js +++ b/lib/deploy/stepFunctions/compileIamRole.js @@ -12,7 +12,7 @@ module.exports = { customRolesProvided.push('role' in stateMachineObj); const stateMachineJson = JSON.stringify(stateMachineObj); - const regex = new RegExp(/"Resource":"([\w\-:*]*)"/gi); + const regex = new RegExp(/"Resource":"([\w\-:*#{}.]*)"/gi); let match = regex.exec(stateMachineJson); while (match !== null) { functionArns.push(match[1]); diff --git a/lib/deploy/stepFunctions/compileIamRole.test.js b/lib/deploy/stepFunctions/compileIamRole.test.js index b6f7d714..23fc91a3 100644 --- a/lib/deploy/stepFunctions/compileIamRole.test.js +++ b/lib/deploy/stepFunctions/compileIamRole.test.js @@ -90,6 +90,7 @@ describe('#compileIamRole', () => { const helloLambda = 'arn:aws:lambda:123:*:function:hello'; const worldLambda = 'arn:aws:lambda:*:*:function:world'; const fooLambda = 'arn:aws:lambda:us-west-2::function:foo_'; + const barLambda = 'arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:bar'; serverless.service.stepFunctions = { stateMachines: { myStateMachine1: { @@ -131,6 +132,19 @@ describe('#compileIamRole', () => { }, }, }, + myStateMachine4: { + name: 'stateMachineBeta4', + definition: { + StartAt: 'Bar', + States: { + Hello: { + Type: 'Task', + Resource: barLambda, + End: true, + }, + }, + }, + }, }, }; @@ -139,6 +153,6 @@ describe('#compileIamRole', () => { .provider.compiledCloudFormationTemplate.Resources.IamRoleStateMachineExecution .Properties.Policies[0]; expect(policy.PolicyDocument.Statement[0].Resource) - .to.be.deep.equal([helloLambda, worldLambda, fooLambda]); + .to.be.deep.equal([helloLambda, worldLambda, fooLambda, barLambda]); }); });