Rule's cloudformation support for updates (#3043)
* add support to update stack using cloudformation * blacked test file
This commit is contained in:
parent
90e200f0f6
commit
149e307bc9
@ -80,6 +80,15 @@ class Rule(BaseModel):
|
|||||||
event_name = properties.get("Name") or resource_name
|
event_name = properties.get("Name") or resource_name
|
||||||
return event_backend.put_rule(name=event_name, **properties)
|
return event_backend.put_rule(name=event_name, **properties)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def update_from_cloudformation_json(
|
||||||
|
cls, original_resource, new_resource_name, cloudformation_json, region_name
|
||||||
|
):
|
||||||
|
original_resource.delete(region_name)
|
||||||
|
return cls.create_from_cloudformation_json(
|
||||||
|
new_resource_name, cloudformation_json, region_name
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete_from_cloudformation_json(
|
def delete_from_cloudformation_json(
|
||||||
cls, resource_name, cloudformation_json, region_name
|
cls, resource_name, cloudformation_json, region_name
|
||||||
|
@ -17,6 +17,7 @@ import boto.sqs
|
|||||||
import boto.vpc
|
import boto.vpc
|
||||||
import boto3
|
import boto3
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
from string import Template
|
||||||
|
|
||||||
from moto import (
|
from moto import (
|
||||||
mock_autoscaling_deprecated,
|
mock_autoscaling_deprecated,
|
||||||
@ -2493,6 +2494,45 @@ def test_stack_events_create_rule_as_target():
|
|||||||
log_groups["logGroups"][0]["retentionInDays"].should.equal(3)
|
log_groups["logGroups"][0]["retentionInDays"].should.equal(3)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_cloudformation
|
||||||
|
@mock_events
|
||||||
|
def test_stack_events_update_rule_integration():
|
||||||
|
events_template = Template(
|
||||||
|
"""{
|
||||||
|
"AWSTemplateFormatVersion": "2010-09-09",
|
||||||
|
"Resources": {
|
||||||
|
"Event": {
|
||||||
|
"Type": "AWS::Events::Rule",
|
||||||
|
"Properties": {
|
||||||
|
"Name": "$Name",
|
||||||
|
"State": "$State",
|
||||||
|
"ScheduleExpression": "rate(5 minutes)",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
} """
|
||||||
|
)
|
||||||
|
|
||||||
|
cf_conn = boto3.client("cloudformation", "us-west-2")
|
||||||
|
|
||||||
|
original_template = events_template.substitute(Name="Foo", State="ENABLED")
|
||||||
|
cf_conn.create_stack(StackName="test_stack", TemplateBody=original_template)
|
||||||
|
|
||||||
|
rules = boto3.client("events", "us-west-2").list_rules()
|
||||||
|
rules["Rules"].should.have.length_of(1)
|
||||||
|
rules["Rules"][0]["Name"].should.equal("Foo")
|
||||||
|
rules["Rules"][0]["State"].should.equal("ENABLED")
|
||||||
|
|
||||||
|
update_template = events_template.substitute(Name="Bar", State="DISABLED")
|
||||||
|
cf_conn.update_stack(StackName="test_stack", TemplateBody=update_template)
|
||||||
|
|
||||||
|
rules = boto3.client("events", "us-west-2").list_rules()
|
||||||
|
|
||||||
|
rules["Rules"].should.have.length_of(1)
|
||||||
|
rules["Rules"][0]["Name"].should.equal("Bar")
|
||||||
|
rules["Rules"][0]["State"].should.equal("DISABLED")
|
||||||
|
|
||||||
|
|
||||||
@mock_cloudformation
|
@mock_cloudformation
|
||||||
@mock_autoscaling
|
@mock_autoscaling
|
||||||
def test_autoscaling_propagate_tags():
|
def test_autoscaling_propagate_tags():
|
||||||
|
Loading…
Reference in New Issue
Block a user