@@ -23,6 +23,9 @@ module.exports = {
2323 let Name ;
2424 let EventBusName ;
2525 let IamRole ;
26+ let InputTransformer ;
27+ let InputPathsMap ;
28+ let InputTemplate ;
2629
2730 if ( typeof eventRule === 'object' ) {
2831 if ( ! eventRule . event ) {
@@ -41,14 +44,17 @@ module.exports = {
4144 }
4245 Input = eventRule . input ;
4346 InputPath = eventRule . inputPath ;
47+ InputTransformer = eventRule . inputTransformer ;
48+ InputPathsMap = InputTransformer && eventRule . inputTransformer . inputPathsMap ;
49+ InputTemplate = InputTransformer && eventRule . inputTransformer . inputTemplate ;
4450 Description = eventRule . description ;
4551 Name = eventRule . name ;
4652 EventBusName = JSON . stringify ( eventRule . eventBusName ) ;
4753 IamRole = eventRule . iamRole ;
4854
49- if ( Input && InputPath ) {
55+ if ( [ Input , InputPath , InputTransformer ] . filter ( Boolean ) . length > 1 ) {
5056 const errorMessage = [
51- 'You can\'t set both input & inputPath properties at the' ,
57+ 'You can\'t set input, inputPath and inputTransformer properties at the' ,
5258 'same time for cloudwatch events.' ,
5359 'Please check the AWS docs for more info' ,
5460 ] . join ( '' ) ;
@@ -62,6 +68,16 @@ module.exports = {
6268 // escape quotes to favor JSON.parse
6369 Input = Input . replace ( / \" / g, '\\"' ) ; // eslint-disable-line
6470 }
71+
72+ // no need to escape quotes in inputPathsMap
73+ // because we add it as an object to the template
74+ if ( InputPathsMap && typeof InputPathsMap === 'object' ) {
75+ InputPathsMap = JSON . stringify ( InputPathsMap ) ;
76+ }
77+ if ( InputTemplate && typeof InputTemplate === 'string' ) {
78+ // escape quotes to favor JSON.parse
79+ InputTemplate = InputTemplate . replace ( / \" / g, '\\"' ) ; // eslint-disable-line
80+ }
6581 } else {
6682 const errorMessage = [
6783 `CloudWatch event of stateMachine "${ stateMachineName } " is not an object` ,
@@ -92,6 +108,10 @@ module.exports = {
92108 "Targets": [{
93109 ${ Input ? `"Input": "${ Input . replace ( / \\ n | \\ r / g, '' ) } ",` : '' }
94110 ${ InputPath ? `"InputPath": "${ InputPath . replace ( / \r ? \n / g, '' ) } ",` : '' }
111+ ${ InputTransformer ? `"InputTransformer": {
112+ "InputPathsMap": ${ InputPathsMap } ,
113+ "InputTemplate": "${ InputTemplate } "
114+ },` : '' }
95115 "Arn": { "Ref": "${ stateMachineLogicalId } " },
96116 "Id": "${ cloudWatchId } ",
97117 ${ IamRole ? `"RoleArn":"${ IamRole } "` : `"RoleArn": {
0 commit comments