diff --git a/examples/2016-10-31/cloudwatch-event-to-msteams/template.yaml b/examples/2016-10-31/cloudwatch-event-to-msteams/template.yaml index 6120d73465..b362a7843f 100644 --- a/examples/2016-10-31/cloudwatch-event-to-msteams/template.yaml +++ b/examples/2016-10-31/cloudwatch-event-to-msteams/template.yaml @@ -45,6 +45,7 @@ Resources: Type: CloudWatchEvent Description: Detects EC2 Security Group Events to Send to Teams Properties: + EventBusName: default Pattern: source: - "aws.ec2" diff --git a/samtranslator/model/events.py b/samtranslator/model/events.py index e5c94208bf..d5774446b0 100644 --- a/samtranslator/model/events.py +++ b/samtranslator/model/events.py @@ -7,6 +7,7 @@ class EventsRule(Resource): resource_type = 'AWS::Events::Rule' property_types = { 'Description': PropertyType(False, is_str()), + 'EventBusName': PropertyType(False, is_str()), 'EventPattern': PropertyType(False, is_type(dict)), 'Name': PropertyType(False, is_str()), 'RoleArn': PropertyType(False, is_str()), diff --git a/samtranslator/model/eventsources/push.py b/samtranslator/model/eventsources/push.py index 62341e983c..a08392be57 100644 --- a/samtranslator/model/eventsources/push.py +++ b/samtranslator/model/eventsources/push.py @@ -143,6 +143,7 @@ class CloudWatchEvent(PushEventSource): resource_type = 'CloudWatchEvent' principal = 'events.amazonaws.com' property_types = { + 'EventBusName': PropertyType(False, is_str()), 'Pattern': PropertyType(False, is_type(dict)), 'Input': PropertyType(False, is_str()), 'InputPath': PropertyType(False, is_str()) @@ -164,6 +165,7 @@ def to_cloudformation(self, **kwargs): resources = [] events_rule = EventsRule(self.logical_id) + events_rule.EventBusName = self.EventBusName events_rule.EventPattern = self.Pattern events_rule.Targets = [self._construct_target(function)] if CONDITION in function.resource_attributes: diff --git a/samtranslator/validator/sam_schema/schema.json b/samtranslator/validator/sam_schema/schema.json index a07d5215ac..c01534263f 100644 --- a/samtranslator/validator/sam_schema/schema.json +++ b/samtranslator/validator/sam_schema/schema.json @@ -336,6 +336,9 @@ "AWS::Serverless::Function.CloudWatchEventEvent": { "additionalProperties": false, "properties": { + "EventBusName": { + "type": "string" + }, "Input": { "type": "string" }, diff --git a/tests/translator/input/cloudwatchevent.yaml b/tests/translator/input/cloudwatchevent.yaml index 28db31f84d..f14ebcb407 100644 --- a/tests/translator/input/cloudwatchevent.yaml +++ b/tests/translator/input/cloudwatchevent.yaml @@ -20,6 +20,7 @@ Resources: OnTerminate: Type: CloudWatchEvent Properties: + EventBusName: ExternalEventBridge Pattern: detail: state: diff --git a/tests/translator/output/aws-cn/cloudwatchevent.json b/tests/translator/output/aws-cn/cloudwatchevent.json index 64003f5575..a4d9169f4d 100644 --- a/tests/translator/output/aws-cn/cloudwatchevent.json +++ b/tests/translator/output/aws-cn/cloudwatchevent.json @@ -90,6 +90,7 @@ ] } }, + "EventBusName": "ExternalEventBridge", "Targets": [ { "Id": "TriggeredFunctionOnTerminateLambdaTarget", diff --git a/tests/translator/output/aws-us-gov/cloudwatchevent.json b/tests/translator/output/aws-us-gov/cloudwatchevent.json index 75979c84b6..62456632fa 100644 --- a/tests/translator/output/aws-us-gov/cloudwatchevent.json +++ b/tests/translator/output/aws-us-gov/cloudwatchevent.json @@ -90,6 +90,7 @@ ] } }, + "EventBusName": "ExternalEventBridge", "Targets": [ { "Id": "TriggeredFunctionOnTerminateLambdaTarget", diff --git a/tests/translator/output/cloudwatchevent.json b/tests/translator/output/cloudwatchevent.json index 53b58bb37c..0def3b60a8 100644 --- a/tests/translator/output/cloudwatchevent.json +++ b/tests/translator/output/cloudwatchevent.json @@ -90,6 +90,7 @@ ] } }, + "EventBusName": "ExternalEventBridge", "Targets": [ { "Id": "TriggeredFunctionOnTerminateLambdaTarget", diff --git a/versions/2016-10-31.md b/versions/2016-10-31.md index 4cdf8a1e44..84bcbcdac9 100644 --- a/versions/2016-10-31.md +++ b/versions/2016-10-31.md @@ -627,6 +627,7 @@ The object describing an event source with type `CloudWatchEvent`. Property Name | Type | Description ---|:---:|--- Pattern | [Event Pattern Object](http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatchEventsandEventPatterns.html) | **Required.** Pattern describing which CloudWatch events trigger the function. Only matching events trigger the function. +EventBusName | `string` | The event bus to associate with this rule. If you omit this, the default event bus is used. Input | `string` | JSON-formatted string to pass to the function as the event body. This value overrides the matched event. InputPath | `string` | JSONPath describing the part of the event to pass to the function.