@@ -12,7 +12,12 @@ 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 )
17+ . replace ( / \\ n | \\ r | \\ n \\ r / g, '' ) ;
18+ } else {
19+ DefinitionString = JSON . stringify ( stateMachineObj . definition , undefined , 2 ) ;
20+ }
1621 } else {
1722 const errorMessage = [
1823 `Missing "definition" property in stateMachine ${ stateMachineName } ` ,
@@ -25,7 +30,7 @@ module.exports = {
2530 if ( stateMachineObj . role ) {
2631 if ( typeof stateMachineObj . role === 'string' ) {
2732 if ( stateMachineObj . role . startsWith ( 'arn:aws' ) ) {
28- RoleArn = `" ${ stateMachineObj . role } "` ;
33+ RoleArn = stateMachineObj . role ;
2934 } else {
3035 const errorMessage = [
3136 `role property in stateMachine "${ stateMachineName } " is not ARN` ,
@@ -43,29 +48,31 @@ module.exports = {
4348 . Error ( errorMessage ) ;
4449 }
4550 } else {
46- RoleArn = '{ "Fn::GetAtt": ["IamRoleStateMachineExecution", "Arn"] }' ;
51+ RoleArn = {
52+ 'Fn::GetAtt' : [
53+ 'IamRoleStateMachineExecution' ,
54+ 'Arn' ,
55+ ] ,
56+ } ;
4757 DependsOn = 'IamRoleStateMachineExecution' ;
4858 }
4959
5060 const stateMachineLogicalId = this . getStateMachineLogicalId ( stateMachineName ,
5161 stateMachineObj ) ;
5262 const stateMachineOutputLogicalId = this
53- . getStateMachineOutputLogicalId ( stateMachineName , stateMachineObj ) ;
54-
55- const stateMachineTemplate = `
63+ . getStateMachineOutputLogicalId ( stateMachineName , stateMachineObj ) ;
64+ const stateMachineTemplate =
5665 {
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- ` ;
66+ Type : 'AWS::StepFunctions::StateMachine' ,
67+ Properties : {
68+ DefinitionString,
69+ RoleArn,
70+ } ,
71+ DependsOn,
72+ } ;
6673
6774 const newStateMachineObject = {
68- [ stateMachineLogicalId ] : JSON . parse ( stateMachineTemplate ) ,
75+ [ stateMachineLogicalId ] : stateMachineTemplate ,
6976 } ;
7077
7178 if ( stateMachineObj . name ) {
0 commit comments