Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions samtranslator/model/eventsources/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Schedule(PushEventSource):
principal = "events.amazonaws.com"
property_types = {
"Schedule": PropertyType(True, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
"RuleName": PropertyType(False, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
"Input": PropertyType(False, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
"Enabled": PropertyType(False, is_type(bool)), # type: ignore[no-untyped-call, no-untyped-call]
"State": PropertyType(False, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
Expand Down Expand Up @@ -180,6 +181,7 @@ class CloudWatchEvent(PushEventSource):
principal = "events.amazonaws.com"
property_types = {
"EventBusName": PropertyType(False, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
"RuleName": PropertyType(False, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
"Pattern": PropertyType(False, is_type(dict)), # type: ignore[no-untyped-call, no-untyped-call]
"DeadLetterConfig": PropertyType(False, is_type(dict)), # type: ignore[no-untyped-call, no-untyped-call]
"RetryPolicy": PropertyType(False, is_type(dict)), # type: ignore[no-untyped-call, no-untyped-call]
Expand Down Expand Up @@ -210,6 +212,7 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def]
events_rule = EventsRule(self.logical_id, attributes=passthrough_resource_attributes) # type: ignore[no-untyped-call]
events_rule.EventBusName = self.EventBusName # type: ignore[attr-defined]
events_rule.EventPattern = self.Pattern # type: ignore[attr-defined]
events_rule.Name = self.RuleName # type: ignore[attr-defined]
source_arn = events_rule.get_runtime_attr("arn") # type: ignore[no-untyped-call]

dlq_queue_arn = None
Expand Down
2 changes: 2 additions & 0 deletions samtranslator/model/stepfunctions/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class CloudWatchEvent(EventSource):
principal = "events.amazonaws.com"
property_types = {
"EventBusName": PropertyType(False, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
"RuleName": PropertyType(False, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
"Pattern": PropertyType(False, is_type(dict)), # type: ignore[no-untyped-call, no-untyped-call]
"Input": PropertyType(False, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
"InputPath": PropertyType(False, is_str()), # type: ignore[no-untyped-call, no-untyped-call]
Expand All @@ -190,6 +191,7 @@ def to_cloudformation(self, resource, **kwargs): # type: ignore[no-untyped-def]
events_rule = EventsRule(self.logical_id, attributes=passthrough_resource_attributes) # type: ignore[no-untyped-call]
events_rule.EventBusName = self.EventBusName # type: ignore[attr-defined]
events_rule.EventPattern = self.Pattern # type: ignore[attr-defined]
events_rule.Name = self.RuleName # type: ignore[attr-defined]

if self.State: # type: ignore[attr-defined]
events_rule.State = self.State # type: ignore[attr-defined]
Expand Down
3 changes: 3 additions & 0 deletions samtranslator/validator/sam_schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@
"State": {
"type": "string"
},
"RuleName": {
"type": "string"
},
"DeadLetterConfig": {
"additionalProperties": false,
"properties": {
Expand Down
6 changes: 6 additions & 0 deletions tests/model/eventsources/test_eventbridge_rule_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ def test_state_when_provided(self):
state = cfn[0].State
self.assertEqual(state, "DISABLED")

def test_name_when_provided(self):
self.eb_event_source.RuleName = "MyRule"
cfn = self.eb_event_source.to_cloudformation(function=self.func)
name = cfn[0].Name
self.assertEqual(name, "MyRule")

def test_to_cloudformation_with_retry_policy(self):
retry_policy = {"MaximumRetryAttempts": "10", "MaximumEventAgeInSeconds": "300"}
self.eb_event_source.RetryPolicy = retry_policy
Expand Down
6 changes: 6 additions & 0 deletions tests/model/stepfunctions/test_eventbridge_rule_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ def test_to_cloudformation_with_state(self):
resources = self.eb_event_source.to_cloudformation(resource=self.state_machine)
state = resources[0].State
self.assertEqual(state, "DISABLED")

def test_name_when_provided(self):
self.eb_event_source.RuleName = "MyRule"
resources = self.eb_event_source.to_cloudformation(resource=self.state_machine)
event_rule = resources[0]
self.assertEqual(event_rule.Name, "MyRule")
1 change: 1 addition & 0 deletions tests/translator/input/eventbridgerule_with_dlq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Resources:
Type: EventBridgeRule
Properties:
EventBusName: ExternalEventBridge
RuleName: MyRule
State: ENABLED
Pattern:
detail:
Expand Down
1 change: 1 addition & 0 deletions tests/translator/input/state_machine_with_cwe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Resources:
CWEvent:
Type: CloudWatchEvent
Properties:
RuleName: MyRule
State: ENABLED
Pattern:
detail:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
]
}
},
"Name": "MyRule",
"State": "ENABLED",
"Targets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
]
}
},
"Name": "MyRule",
"State": "ENABLED",
"Targets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
]
}
},
"Name": "MyRule",
"State": "ENABLED",
"Targets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
]
}
},
"Name": "MyRule",
"State": "ENABLED",
"Targets": [
{
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/eventbridgerule_with_dlq.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
]
}
},
"Name": "MyRule",
"State": "ENABLED",
"Targets": [
{
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/state_machine_with_cwe.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
]
}
},
"Name": "MyRule",
"State": "ENABLED",
"Targets": [
{
Expand Down