Skip to content

Commit b9ff754

Browse files
authored
Merge pull request #406 from Kevchan85/master
bug(eventbus): stringify eventbus name
2 parents ae5c5f9 + 9fdf996 commit b9ff754

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

lib/deploy/events/cloudWatchEvent/compileCloudWatchEventEvents.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module.exports = {
4343
InputPath = eventRule.inputPath;
4444
Description = eventRule.description;
4545
Name = eventRule.name;
46-
EventBusName = eventRule.eventBusName;
46+
EventBusName = JSON.stringify(eventRule.eventBusName);
4747
IamRole = eventRule.iamRole;
4848

4949
if (Input && InputPath) {
@@ -84,7 +84,7 @@ module.exports = {
8484
{
8585
"Type": "AWS::Events::Rule",
8686
"Properties": {
87-
${EventBusName ? `"EventBusName": "${EventBusName}",` : ''}
87+
${EventBusName ? `"EventBusName": ${EventBusName},` : ''}
8888
"EventPattern": ${EventPattern.replace(/\\n|\\r/g, '')},
8989
"State": "${State}",
9090
${Description ? `"Description": "${Description}",` : ''}

lib/deploy/events/cloudWatchEvent/compileCloudWatchEventEvents.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,36 @@ describe('awsCompileCloudWatchEventEvents', () => {
297297
.Properties.EventBusName).to.equal('custom-event-bus');
298298
});
299299

300+
itParam('should respect eventBusName intrinsic function', ['cloudwatchEvent', 'eventBridge'], (source) => {
301+
serverlessStepFunctions.serverless.service.stepFunctions = {
302+
stateMachines: {
303+
first: {
304+
events: [
305+
{
306+
[source]: {
307+
event: {
308+
source: ['aws.ec2'],
309+
'detail-type': ['EC2 Instance State-change Notification'],
310+
detail: { state: ['pending'] },
311+
},
312+
enabled: false,
313+
input: '{"key":"value"}',
314+
name: 'test-event-name',
315+
eventBusName: '{"Fn::If": [isLocal, "develop", "production"}',
316+
},
317+
},
318+
],
319+
},
320+
},
321+
};
322+
323+
serverlessStepFunctions.compileCloudWatchEventEvents();
324+
325+
expect(serverlessStepFunctions.serverless.service
326+
.provider.compiledCloudFormationTemplate.Resources.FirstEventsRuleCloudWatchEvent1
327+
.Properties.EventBusName).to.equal('{"Fn::If": [isLocal, "develop", "production"}');
328+
});
329+
300330
itParam('should respect input variable as an object', ['cloudwatchEvent', 'eventBridge'], (source) => {
301331
serverlessStepFunctions.serverless.service.stepFunctions = {
302332
stateMachines: {

0 commit comments

Comments
 (0)