add support for Fn::GetAtt in event's cloudformation
This commit is contained in:
parent
af08d71310
commit
c15ca133b8
@ -59,6 +59,14 @@ class Rule(BaseModel):
|
|||||||
if index is not None:
|
if index is not None:
|
||||||
self.targets.pop(index)
|
self.targets.pop(index)
|
||||||
|
|
||||||
|
def get_cfn_attribute(self, attribute_name):
|
||||||
|
from moto.cloudformation.exceptions import UnformattedGetAttTemplateException
|
||||||
|
|
||||||
|
if attribute_name == "Arn":
|
||||||
|
return self.arn
|
||||||
|
|
||||||
|
raise UnformattedGetAttTemplateException()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_from_cloudformation_json(
|
def create_from_cloudformation_json(
|
||||||
cls, resource_name, cloudformation_json, region_name
|
cls, resource_name, cloudformation_json, region_name
|
||||||
|
@ -2463,3 +2463,40 @@ def test_stack_events_create_rule_without_name_integration():
|
|||||||
|
|
||||||
rules = boto3.client("events", "us-west-2").list_rules()
|
rules = boto3.client("events", "us-west-2").list_rules()
|
||||||
rules["Rules"][0]["Name"].should.contain("test_stack-Event-")
|
rules["Rules"][0]["Name"].should.contain("test_stack-Event-")
|
||||||
|
|
||||||
|
|
||||||
|
@mock_cloudformation
|
||||||
|
@mock_events
|
||||||
|
@mock_logs
|
||||||
|
def test_stack_events_create_rule_as_target():
|
||||||
|
events_template = {
|
||||||
|
"AWSTemplateFormatVersion": "2010-09-09",
|
||||||
|
"Resources": {
|
||||||
|
"SecurityGroup": {
|
||||||
|
"Type": "AWS::Logs::LogGroup",
|
||||||
|
"Properties": {
|
||||||
|
"LogGroupName": {"Fn::GetAtt": ["Event", "Arn"]},
|
||||||
|
"RetentionInDays": 3,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Event": {
|
||||||
|
"Type": "AWS::Events::Rule",
|
||||||
|
"Properties": {
|
||||||
|
"State": "ENABLED",
|
||||||
|
"ScheduleExpression": "rate(5 minutes)",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
cf_conn = boto3.client("cloudformation", "us-west-2")
|
||||||
|
cf_conn.create_stack(
|
||||||
|
StackName="test_stack", TemplateBody=json.dumps(events_template),
|
||||||
|
)
|
||||||
|
|
||||||
|
rules = boto3.client("events", "us-west-2").list_rules()
|
||||||
|
log_groups = boto3.client("logs", "us-west-2").describe_log_groups()
|
||||||
|
|
||||||
|
rules["Rules"][0]["Name"].should.contain("test_stack-Event-")
|
||||||
|
|
||||||
|
log_groups["logGroups"][0]["logGroupName"].should.equal(rules["Rules"][0]["Arn"])
|
||||||
|
log_groups["logGroups"][0]["retentionInDays"].should.equal(3)
|
||||||
|
Loading…
Reference in New Issue
Block a user