@@ -12,7 +12,11 @@ module.exports = {
1212 let DependsOn ;
1313
1414 if ( stateMachineObj . definition ) {
15- DefinitionString = JSON . stringify ( stateMachineObj . definition ) ;
15+ if ( typeof stateMachineObj . definition === 'string' ) {
16+ DefinitionString = JSON . stringify ( stateMachineObj . definition ) . replace ( / \\ n | \\ r | \\ n \\ r / g, '' ) ;
17+ } else {
18+ DefinitionString = JSON . stringify ( stateMachineObj . definition , undefined , 2 ) ;
19+ }
1620 } else {
1721 const errorMessage = [
1822 `Missing "definition" property in stateMachine ${ stateMachineName } ` ,
@@ -25,7 +29,7 @@ module.exports = {
2529 if ( stateMachineObj . role ) {
2630 if ( typeof stateMachineObj . role === 'string' ) {
2731 if ( stateMachineObj . role . startsWith ( 'arn:aws' ) ) {
28- RoleArn = `" ${ stateMachineObj . role } "` ;
32+ RoleArn = stateMachineObj . role ;
2933 } else {
3034 const errorMessage = [
3135 `role property in stateMachine "${ stateMachineName } " is not ARN` ,
@@ -43,29 +47,31 @@ module.exports = {
4347 . Error ( errorMessage ) ;
4448 }
4549 } else {
46- RoleArn = '{ "Fn::GetAtt": ["IamRoleStateMachineExecution", "Arn"] }' ;
50+ RoleArn = {
51+ 'Fn::GetAtt' : [
52+ 'IamRoleStateMachineExecution' ,
53+ 'Arn' ,
54+ ] ,
55+ } ;
4756 DependsOn = 'IamRoleStateMachineExecution' ;
4857 }
4958
5059 const stateMachineLogicalId = this . getStateMachineLogicalId ( stateMachineName ,
5160 stateMachineObj ) ;
5261 const stateMachineOutputLogicalId = this
53- . getStateMachineOutputLogicalId ( stateMachineName , stateMachineObj ) ;
54-
55- const stateMachineTemplate = `
62+ . getStateMachineOutputLogicalId ( stateMachineName , stateMachineObj ) ;
63+ const stateMachineTemplate =
5664 {
57- "Type": "AWS::StepFunctions::StateMachine",
58- "Properties": {
59- "DefinitionString": ${ JSON . stringify ( DefinitionString
60- . replace ( / \\ n | \\ r | \\ n \\ r / g, '' ) ) } ,
61- "RoleArn": ${ RoleArn }
62- }
63- ${ DependsOn ? `,"DependsOn": "${ DependsOn } "` : '' }
64- }
65- ` ;
65+ Type : 'AWS::StepFunctions::StateMachine' ,
66+ Properties : {
67+ DefinitionString,
68+ RoleArn,
69+ } ,
70+ DependsOn,
71+ } ;
6672
6773 const newStateMachineObject = {
68- [ stateMachineLogicalId ] : JSON . parse ( stateMachineTemplate ) ,
74+ [ stateMachineLogicalId ] : stateMachineTemplate ,
6975 } ;
7076
7177 if ( stateMachineObj . name ) {
0 commit comments