From f3b73542e7ea6fd0b9cdf67bbfcd58a3ed947631 Mon Sep 17 00:00:00 2001 From: Anthony Schott Date: Tue, 30 Oct 2018 19:12:06 -0700 Subject: [PATCH] Add dollar sign to function arn regex --- lib/deploy/stepFunctions/compileIamRole.js | 2 +- lib/deploy/stepFunctions/compileIamRole.test.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/deploy/stepFunctions/compileIamRole.js b/lib/deploy/stepFunctions/compileIamRole.js index 447a8048..9e9f32c5 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 23fc91a3..437258b4 100644 --- a/lib/deploy/stepFunctions/compileIamRole.test.js +++ b/lib/deploy/stepFunctions/compileIamRole.test.js @@ -91,6 +91,7 @@ describe('#compileIamRole', () => { 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'; + const bazLambda = 'arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${baz}'; serverless.service.stepFunctions = { stateMachines: { myStateMachine1: { @@ -145,6 +146,19 @@ describe('#compileIamRole', () => { }, }, }, + myStateMachine5: { + name: 'stateMachineBeta5', + definition: { + StartAt: 'Baz', + States: { + Hello: { + Type: 'Task', + Resource: bazLambda, + End: true, + }, + }, + }, + }, }, }; @@ -153,6 +167,6 @@ describe('#compileIamRole', () => { .provider.compiledCloudFormationTemplate.Resources.IamRoleStateMachineExecution .Properties.Policies[0]; expect(policy.PolicyDocument.Statement[0].Resource) - .to.be.deep.equal([helloLambda, worldLambda, fooLambda, barLambda]); + .to.be.deep.equal([helloLambda, worldLambda, fooLambda, barLambda, bazLambda]); }); });