diff --git a/lib/deploy/stepFunctions/compileIamRole.js b/lib/deploy/stepFunctions/compileIamRole.js index 5e5bff2f..f0d25efc 100644 --- a/lib/deploy/stepFunctions/compileIamRole.js +++ b/lib/deploy/stepFunctions/compileIamRole.js @@ -19,7 +19,7 @@ function getTaskStates(states) { return getTaskStates(parallelStates); } case 'Map': { - const mapStates = state.Iterator.States; + const mapStates = state.ItemProcessor ? state.ItemProcessor.States : state.Iterator.States; return getTaskStates(mapStates); } default: { diff --git a/lib/deploy/stepFunctions/compileStateMachines.test.js b/lib/deploy/stepFunctions/compileStateMachines.test.js index 8f770245..1b17a39c 100644 --- a/lib/deploy/stepFunctions/compileStateMachines.test.js +++ b/lib/deploy/stepFunctions/compileStateMachines.test.js @@ -1647,4 +1647,85 @@ describe('#compileStateMachines', () => { // Definition is invalid and validate=true, should throw expect(() => serverlessStepFunctions.compileStateMachines()).to.throw(Error); }); + + it('should compile with the old Iterator', () => { + serverless.service.stepFunctions = { + stateMachines: { + myStateMachine1: { + id: 'Test', + name: 'test', + definition: { + StartAt: 'One', + States: { + One: { + Type: 'Map', + Iterator: { + StartAt: 'Two', + States: { + Two: { + Type: 'Wait', + Seconds: 10, + End: true, + }, + }, + }, + End: true, + }, + }, + }, + }, + }, + }; + + serverlessStepFunctions.compileStateMachines(); + const stateMachine = serverlessStepFunctions.serverless.service + .provider.compiledCloudFormationTemplate.Resources + .Test; + + expect(stateMachine.Properties.DefinitionString).to.not.haveOwnProperty('Fn::Sub'); + const stateMachineObj = JSON.parse(stateMachine.Properties.DefinitionString); + expect(stateMachineObj.States).to.haveOwnProperty('One'); + }); + + it('should compile with the new ItemProcessor', () => { + serverless.service.stepFunctions = { + stateMachines: { + myStateMachine1: { + id: 'Test', + name: 'test', + definition: { + StartAt: 'One', + States: { + One: { + Type: 'Map', + ItemProcessor: { + ProcessorConfig: { + Mode: 'INLINE', + }, + StartAt: 'Two', + States: { + Two: { + Type: 'Wait', + Seconds: 10, + End: true, + }, + }, + }, + End: true, + }, + }, + }, + }, + }, + }; + + serverlessStepFunctions.compileStateMachines(); + const stateMachine = serverlessStepFunctions.serverless.service + .provider.compiledCloudFormationTemplate.Resources + .Test; + + expect(stateMachine.Properties.DefinitionString).to.not.haveOwnProperty('Fn::Sub'); + const stateMachineObj = JSON.parse(stateMachine.Properties.DefinitionString); + expect(stateMachineObj.States).to.haveOwnProperty('One'); + }); });