Merge in master.
This commit is contained in:
commit
3b4ef2cf15
26 changed files with 565 additions and 65 deletions
|
|
@ -236,6 +236,10 @@ template = {
|
|||
"Ref": "AWS::StackId"
|
||||
},
|
||||
"Key": "Application"
|
||||
},
|
||||
{
|
||||
"Value": "Bar",
|
||||
"Key": "Foo"
|
||||
}
|
||||
],
|
||||
"SecurityGroupIds": [
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import sure # noqa
|
|||
import tests.backport_assert_raises # noqa
|
||||
from nose.tools import assert_raises
|
||||
|
||||
from moto import mock_cloudformation_deprecated, mock_s3_deprecated
|
||||
from moto import mock_cloudformation_deprecated, mock_s3_deprecated, mock_route53_deprecated
|
||||
from moto.cloudformation import cloudformation_backends
|
||||
|
||||
dummy_template = {
|
||||
|
|
@ -69,6 +69,57 @@ def test_create_stack():
|
|||
})
|
||||
|
||||
|
||||
@mock_cloudformation_deprecated
|
||||
@mock_route53_deprecated
|
||||
def test_create_stack_hosted_zone_by_id():
|
||||
conn = boto.connect_cloudformation()
|
||||
dummy_template = {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "Stack 1",
|
||||
"Parameters": {
|
||||
},
|
||||
"Resources": {
|
||||
"Bar": {
|
||||
"Type" : "AWS::Route53::HostedZone",
|
||||
"Properties" : {
|
||||
"Name" : "foo.bar.baz",
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
dummy_template2 = {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "Stack 2",
|
||||
"Parameters": {
|
||||
"ZoneId": { "Type": "String" }
|
||||
},
|
||||
"Resources": {
|
||||
"Foo": {
|
||||
"Properties": {
|
||||
"HostedZoneId": {"Ref": "ZoneId"},
|
||||
"RecordSets": []
|
||||
},
|
||||
"Type": "AWS::Route53::RecordSetGroup"
|
||||
}
|
||||
},
|
||||
}
|
||||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=json.dumps(dummy_template),
|
||||
parameters={}.items()
|
||||
)
|
||||
r53_conn = boto.connect_route53()
|
||||
zone_id = r53_conn.get_zones()[0].id
|
||||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=json.dumps(dummy_template2),
|
||||
parameters={"ZoneId": zone_id}.items()
|
||||
)
|
||||
|
||||
stack = conn.describe_stacks()[0]
|
||||
assert stack.list_resources()
|
||||
|
||||
|
||||
@mock_cloudformation_deprecated
|
||||
def test_creating_stacks_across_regions():
|
||||
west1_conn = boto.cloudformation.connect_to_region("us-west-1")
|
||||
|
|
@ -281,6 +332,60 @@ def test_cloudformation_params():
|
|||
param.value.should.equal('testing123')
|
||||
|
||||
|
||||
@mock_cloudformation_deprecated
|
||||
def test_cloudformation_params_conditions_and_resources_are_distinct():
|
||||
dummy_template = {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "Stack 1",
|
||||
"Conditions": {
|
||||
"FooEnabled": {
|
||||
"Fn::Equals": [
|
||||
{
|
||||
"Ref": "FooEnabled"
|
||||
},
|
||||
"true"
|
||||
]
|
||||
},
|
||||
"FooDisabled": {
|
||||
"Fn::Not": [
|
||||
{
|
||||
"Fn::Equals": [
|
||||
{
|
||||
"Ref": "FooEnabled"
|
||||
},
|
||||
"true"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Parameters": {
|
||||
"FooEnabled": {
|
||||
"Type": "String",
|
||||
"AllowedValues": [
|
||||
"true",
|
||||
"false"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Resources": {
|
||||
"Bar": {
|
||||
"Properties": {
|
||||
"CidrBlock": "192.168.0.0/16",
|
||||
},
|
||||
"Condition": "FooDisabled",
|
||||
"Type": "AWS::EC2::VPC"
|
||||
}
|
||||
}
|
||||
}
|
||||
dummy_template_json = json.dumps(dummy_template)
|
||||
cfn = boto.connect_cloudformation()
|
||||
cfn.create_stack('test_stack1', template_body=dummy_template_json, parameters=[('FooEnabled', 'true')])
|
||||
stack = cfn.describe_stacks('test_stack1')[0]
|
||||
resources = stack.list_resources()
|
||||
assert not [resource for resource in resources if resource.logical_resource_id == 'Bar']
|
||||
|
||||
|
||||
@mock_cloudformation_deprecated
|
||||
def test_stack_tags():
|
||||
conn = boto.connect_cloudformation()
|
||||
|
|
@ -341,6 +446,42 @@ def test_update_stack():
|
|||
})
|
||||
|
||||
|
||||
@mock_cloudformation_deprecated
|
||||
def test_update_stack_with_parameters():
|
||||
dummy_template = {
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Description": "Stack",
|
||||
"Resources": {
|
||||
"VPC": {
|
||||
"Properties": {
|
||||
"CidrBlock": {"Ref": "Bar"}
|
||||
},
|
||||
"Type": "AWS::EC2::VPC"
|
||||
}
|
||||
},
|
||||
"Parameters": {
|
||||
"Bar": {
|
||||
"Type": "String"
|
||||
}
|
||||
}
|
||||
}
|
||||
dummy_template_json = json.dumps(dummy_template)
|
||||
conn = boto.connect_cloudformation()
|
||||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=dummy_template_json,
|
||||
parameters=[("Bar", "192.168.0.0/16")]
|
||||
)
|
||||
conn.update_stack(
|
||||
"test_stack",
|
||||
template_body=dummy_template_json,
|
||||
parameters=[("Bar", "192.168.0.1/16")]
|
||||
)
|
||||
|
||||
stack = conn.describe_stacks()[0]
|
||||
assert stack.parameters[0].value == "192.168.0.1/16"
|
||||
|
||||
|
||||
@mock_cloudformation_deprecated
|
||||
def test_update_stack_when_rolled_back():
|
||||
conn = boto.connect_cloudformation()
|
||||
|
|
@ -374,16 +515,21 @@ def test_describe_stack_events_shows_create_update_and_delete():
|
|||
events[0].resource_type.should.equal("AWS::CloudFormation::Stack")
|
||||
events[-1].resource_type.should.equal("AWS::CloudFormation::Stack")
|
||||
|
||||
# testing ordering of stack events without assuming resource events will
|
||||
# not exist
|
||||
# testing ordering of stack events without assuming resource events will not exist
|
||||
# the AWS API returns events in reverse chronological order
|
||||
stack_events_to_look_for = iter([
|
||||
("CREATE_IN_PROGRESS", "User Initiated"), ("CREATE_COMPLETE", None),
|
||||
("UPDATE_IN_PROGRESS", "User Initiated"), ("UPDATE_COMPLETE", None),
|
||||
("DELETE_IN_PROGRESS", "User Initiated"), ("DELETE_COMPLETE", None)])
|
||||
("DELETE_COMPLETE", None),
|
||||
("DELETE_IN_PROGRESS", "User Initiated"),
|
||||
("UPDATE_COMPLETE", None),
|
||||
("UPDATE_IN_PROGRESS", "User Initiated"),
|
||||
("CREATE_COMPLETE", None),
|
||||
("CREATE_IN_PROGRESS", "User Initiated"),
|
||||
])
|
||||
try:
|
||||
for event in events:
|
||||
event.stack_id.should.equal(stack_id)
|
||||
event.stack_name.should.equal("test_stack")
|
||||
event.event_id.should.match(r"[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}")
|
||||
|
||||
if event.resource_type == "AWS::CloudFormation::Stack":
|
||||
event.logical_resource_id.should.equal("test_stack")
|
||||
|
|
|
|||
|
|
@ -354,16 +354,21 @@ def test_stack_events():
|
|||
events[0].resource_type.should.equal("AWS::CloudFormation::Stack")
|
||||
events[-1].resource_type.should.equal("AWS::CloudFormation::Stack")
|
||||
|
||||
# testing ordering of stack events without assuming resource events will
|
||||
# not exist
|
||||
# testing ordering of stack events without assuming resource events will not exist
|
||||
# the AWS API returns events in reverse chronological order
|
||||
stack_events_to_look_for = iter([
|
||||
("CREATE_IN_PROGRESS", "User Initiated"), ("CREATE_COMPLETE", None),
|
||||
("UPDATE_IN_PROGRESS", "User Initiated"), ("UPDATE_COMPLETE", None),
|
||||
("DELETE_IN_PROGRESS", "User Initiated"), ("DELETE_COMPLETE", None)])
|
||||
("DELETE_COMPLETE", None),
|
||||
("DELETE_IN_PROGRESS", "User Initiated"),
|
||||
("UPDATE_COMPLETE", None),
|
||||
("UPDATE_IN_PROGRESS", "User Initiated"),
|
||||
("CREATE_COMPLETE", None),
|
||||
("CREATE_IN_PROGRESS", "User Initiated"),
|
||||
])
|
||||
try:
|
||||
for event in events:
|
||||
event.stack_id.should.equal(stack.stack_id)
|
||||
event.stack_name.should.equal("test_stack")
|
||||
event.event_id.should.match(r"[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}")
|
||||
|
||||
if event.resource_type == "AWS::CloudFormation::Stack":
|
||||
event.logical_resource_id.should.equal("test_stack")
|
||||
|
|
|
|||
|
|
@ -548,6 +548,7 @@ def test_autoscaling_group_with_elb():
|
|||
"LaunchConfigurationName": {"Ref": "my-launch-config"},
|
||||
"MinSize": "2",
|
||||
"MaxSize": "2",
|
||||
"DesiredCapacity": "2",
|
||||
"LoadBalancerNames": [{"Ref": "my-elb"}]
|
||||
},
|
||||
},
|
||||
|
|
@ -631,6 +632,7 @@ def test_autoscaling_group_update():
|
|||
"LaunchConfigurationName": {"Ref": "my-launch-config"},
|
||||
"MinSize": "2",
|
||||
"MaxSize": "2",
|
||||
"DesiredCapacity": "2"
|
||||
},
|
||||
},
|
||||
|
||||
|
|
@ -655,6 +657,7 @@ def test_autoscaling_group_update():
|
|||
asg = autoscale_conn.get_all_groups()[0]
|
||||
asg.min_size.should.equal(2)
|
||||
asg.max_size.should.equal(2)
|
||||
asg.desired_capacity.should.equal(2)
|
||||
|
||||
asg_template['Resources']['my-as-group']['Properties']['MaxSize'] = 3
|
||||
asg_template_json = json.dumps(asg_template)
|
||||
|
|
@ -665,6 +668,7 @@ def test_autoscaling_group_update():
|
|||
asg = autoscale_conn.get_all_groups()[0]
|
||||
asg.min_size.should.equal(2)
|
||||
asg.max_size.should.equal(3)
|
||||
asg.desired_capacity.should.equal(2)
|
||||
|
||||
|
||||
@mock_ec2_deprecated()
|
||||
|
|
@ -693,6 +697,7 @@ def test_vpc_single_instance_in_subnet():
|
|||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
reservation = ec2_conn.get_all_instances()[0]
|
||||
instance = reservation.instances[0]
|
||||
instance.tags["Foo"].should.equal("Bar")
|
||||
# Check that the EIP is attached the the EC2 instance
|
||||
eip = ec2_conn.get_all_addresses()[0]
|
||||
eip.domain.should.equal('vpc')
|
||||
|
|
@ -714,7 +719,7 @@ def test_vpc_single_instance_in_subnet():
|
|||
|
||||
eip_resource = [
|
||||
resource for resource in resources if resource.resource_type == 'AWS::EC2::EIP'][0]
|
||||
eip_resource.physical_resource_id.should.equal(eip.allocation_id)
|
||||
eip_resource.physical_resource_id.should.equal(eip.public_ip)
|
||||
|
||||
|
||||
@mock_cloudformation()
|
||||
|
|
@ -1027,7 +1032,7 @@ def test_vpc_eip():
|
|||
resources = stack.describe_resources()
|
||||
cfn_eip = [
|
||||
resource for resource in resources if resource.resource_type == 'AWS::EC2::EIP'][0]
|
||||
cfn_eip.physical_resource_id.should.equal(eip.allocation_id)
|
||||
cfn_eip.physical_resource_id.should.equal(eip.public_ip)
|
||||
|
||||
|
||||
@mock_ec2_deprecated()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue