@@ -22,6 +22,7 @@ module.exports = {
22
22
let Description ;
23
23
let Name ;
24
24
let EventBusName ;
25
+ let IamRole ;
25
26
26
27
if ( typeof eventRule === 'object' ) {
27
28
if ( ! eventRule . event ) {
@@ -43,6 +44,7 @@ module.exports = {
43
44
Description = eventRule . description ;
44
45
Name = eventRule . name ;
45
46
EventBusName = eventRule . eventBusName ;
47
+ IamRole = eventRule . iamRole ;
46
48
47
49
if ( Input && InputPath ) {
48
50
const errorMessage = [
@@ -92,12 +94,12 @@ module.exports = {
92
94
${ InputPath ? `"InputPath": "${ InputPath . replace ( / \r ? \n / g, '' ) } ",` : '' }
93
95
"Arn": { "Ref": "${ stateMachineLogicalId } " },
94
96
"Id": "${ cloudWatchId } ",
95
- "RoleArn": {
97
+ ${ IamRole ? `"RoleArn":" ${ IamRole } "` : ` "RoleArn": {
96
98
"Fn::GetAtt": [
97
99
"${ cloudWatchIamRoleLogicalId } ",
98
100
"Arn"
99
101
]
100
- }
102
+ }` }
101
103
}]
102
104
}
103
105
}
@@ -146,12 +148,17 @@ module.exports = {
146
148
[ cloudWatchLogicalId ] : JSON . parse ( cloudWatchEventRuleTemplate ) ,
147
149
} ;
148
150
149
- const newPermissionObject = {
150
- [ cloudWatchIamRoleLogicalId ] : JSON . parse ( iamRoleTemplate ) ,
151
- } ;
151
+ const objectsToMerge = [ newCloudWatchEventRuleObject ]
152
+
153
+ if ( ! IamRole ) {
154
+ const newPermissionObject = {
155
+ [ cloudWatchIamRoleLogicalId ] : JSON . parse ( iamRoleTemplate ) ,
156
+ } ;
157
+
158
+ objectsToMerge . push ( newPermissionObject )
159
+ }
152
160
153
- _ . merge ( this . serverless . service . provider . compiledCloudFormationTemplate . Resources ,
154
- newCloudWatchEventRuleObject , newPermissionObject ) ;
161
+ _ . merge ( this . serverless . service . provider . compiledCloudFormationTemplate . Resources , ...objectsToMerge ) ;
155
162
}
156
163
} ) ;
157
164
}
0 commit comments