#1954 - CF - Check stack name in use

This commit is contained in:
Bert Blommers 2020-06-14 11:31:44 +01:00
commit 4556a2f96f
3 changed files with 41 additions and 4 deletions

View file

@ -98,12 +98,12 @@ def test_create_stack_hosted_zone_by_id():
},
}
conn.create_stack(
"test_stack", template_body=json.dumps(dummy_template), parameters={}.items()
"test_stack1", 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",
"test_stack2",
template_body=json.dumps(dummy_template2),
parameters={"ZoneId": zone_id}.items(),
)

View file

@ -919,7 +919,9 @@ def test_execute_change_set_w_name():
def test_describe_stack_pagination():
conn = boto3.client("cloudformation", region_name="us-east-1")
for i in range(100):
conn.create_stack(StackName="test_stack", TemplateBody=dummy_template_json)
conn.create_stack(
StackName="test_stack_{}".format(i), TemplateBody=dummy_template_json
)
resp = conn.describe_stacks()
stacks = resp["Stacks"]
@ -1211,7 +1213,8 @@ def test_list_exports_with_token():
# Add index to ensure name is unique
dummy_output_template["Outputs"]["StackVPC"]["Export"]["Name"] += str(i)
cf.create_stack(
StackName="test_stack", TemplateBody=json.dumps(dummy_output_template)
StackName="test_stack_{}".format(i),
TemplateBody=json.dumps(dummy_output_template),
)
exports = cf.list_exports()
exports["Exports"].should.have.length_of(100)
@ -1273,3 +1276,16 @@ def test_non_json_redrive_policy():
stack.Resource("MainQueue").resource_status.should.equal("CREATE_COMPLETE")
stack.Resource("DeadLetterQueue").resource_status.should.equal("CREATE_COMPLETE")
@mock_cloudformation
def test_boto3_create_duplicate_stack():
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
cf_conn.create_stack(
StackName="test_stack", TemplateBody=dummy_template_json,
)
with assert_raises(ClientError):
cf_conn.create_stack(
StackName="test_stack", TemplateBody=dummy_template_json,
)