Commit 57e1723 1 parent fcf2b3c commit 57e1723 Copy full SHA for 57e1723
File tree 2 files changed +56
-4
lines changed
2 files changed +56
-4
lines changed Original file line number Diff line number Diff line change @@ -597,14 +597,15 @@ module.exports = {
597
597
logger . config ( this . serverless , this . v3Api ) ;
598
598
const service = this . serverless . service ;
599
599
const permissionsBoundary = service . provider . rolePermissionsBoundary ;
600
- this . getAllStateMachines ( ) . forEach ( ( stateMachineName ) => {
601
- const stateMachineObj = this . getStateMachine ( stateMachineName ) ;
600
+ this . getAllStateMachines ( ) . forEach ( ( stateMachineId ) => {
601
+ const stateMachineObj = this . getStateMachine ( stateMachineId ) ;
602
+ const stateMachineName = stateMachineObj . name || stateMachineId ;
602
603
if ( stateMachineObj . role ) {
603
604
return ;
604
605
}
605
606
606
607
if ( ! stateMachineObj . definition ) {
607
- throw new Error ( `Missing "definition" for state machine ${ stateMachineName } ` ) ;
608
+ throw new Error ( `Missing "definition" for state machine ${ stateMachineId } ` ) ;
608
609
}
609
610
610
611
const taskStates = getTaskStates ( stateMachineObj . definition . States , stateMachineName ) ;
@@ -646,7 +647,7 @@ module.exports = {
646
647
}
647
648
648
649
const stateMachineLogicalId = this . getStateMachineLogicalId (
649
- stateMachineName ,
650
+ stateMachineId ,
650
651
stateMachineObj ,
651
652
) ;
652
653
const iamRoleStateMachineLogicalId = `${ stateMachineLogicalId } Role` ;
Original file line number Diff line number Diff line change @@ -2344,6 +2344,57 @@ describe('#compileIamRole', () => {
2344
2344
] ) ;
2345
2345
} ) ;
2346
2346
2347
+ it ( 'should support custom state machine names in a Distributed Map' , ( ) => {
2348
+ const getStateMachine = ( id , lambdaArn ) => ( {
2349
+ id,
2350
+ name : 'DistributedMapper' ,
2351
+ definition : {
2352
+ StartAt : 'A' ,
2353
+ States : {
2354
+ A : {
2355
+ Type : 'Map' ,
2356
+ ItemProcessor : {
2357
+ ProcessorConfig : {
2358
+ Mode : 'DISTRIBUTED' ,
2359
+ } ,
2360
+ StartAt : 'B' ,
2361
+ States : {
2362
+ B : {
2363
+ Type : 'Task' ,
2364
+ Resource : lambdaArn ,
2365
+ End : true ,
2366
+ } ,
2367
+ } ,
2368
+ } ,
2369
+ End : true ,
2370
+ } ,
2371
+ } ,
2372
+ } ,
2373
+ } ) ;
2374
+
2375
+ serverless . service . stepFunctions = {
2376
+ stateMachines : {
2377
+ myStateMachine : getStateMachine ( 'StateMachine1' , 'arn:aws:lambda:us-west-2:1234567890:function:foo' ) ,
2378
+ } ,
2379
+ } ;
2380
+
2381
+ serverlessStepFunctions . compileIamRole ( ) ;
2382
+
2383
+ const statements = serverlessStepFunctions . serverless . service
2384
+ . provider . compiledCloudFormationTemplate . Resources . StateMachine1Role
2385
+ . Properties . Policies [ 0 ] . PolicyDocument . Statement ;
2386
+
2387
+ const stepFunctionPermission = statements . filter ( s => _ . isEqual ( s . Action , [ 'states:StartExecution' ] ) ) ;
2388
+ expect ( stepFunctionPermission ) . to . have . lengthOf ( 1 ) ;
2389
+ expect ( stepFunctionPermission [ 0 ] . Resource ) . to . deep . eq ( [ {
2390
+ 'Fn::Sub' : [
2391
+ 'arn:aws:states:${AWS::Region}:${AWS::AccountId}:stateMachine:DistributedMapper' ,
2392
+ { } ,
2393
+ ] ,
2394
+ } ,
2395
+ ] ) ;
2396
+ } ) ;
2397
+
2347
2398
it ( 'should support nested Map state type' , ( ) => {
2348
2399
const getStateMachine = ( id , lambdaArn1 , lambdaArn2 ) => ( {
2349
2400
id,
You can’t perform that action at this time.
0 commit comments