Fix CloudFormation create_stack returning stack_id with wrong region (#4302)

This commit is contained in:
Paul Roberts 2021-09-17 15:45:11 -07:00 committed by GitHub
parent dec35c12c2
commit 65c29e1f5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 1 deletions

View File

@ -623,7 +623,7 @@ class CloudFormationBackend(BaseBackend):
tags=None,
role_arn=None,
):
stack_id = generate_stack_id(name)
stack_id = generate_stack_id(name, region_name)
new_stack = FakeStack(
stack_id=stack_id,
name=name,

View File

@ -85,6 +85,33 @@ def test_create_stack():
conn.create_stack("test_stack", template_body=dummy_template_json)
stack = conn.describe_stacks()[0]
stack.stack_id.should.contain(
"arn:aws:cloudformation:us-east-1:123456789:stack/test_stack/"
)
stack.stack_name.should.equal("test_stack")
stack.get_template().should.equal(
{
"GetTemplateResponse": {
"GetTemplateResult": {
"TemplateBody": dummy_template_json,
"ResponseMetadata": {
"RequestId": "2d06e36c-ac1d-11e0-a958-f9382b6eb86bEXAMPLE"
},
}
}
}
)
@mock_cloudformation_deprecated
def test_create_stack_with_other_region():
conn = boto.cloudformation.connect_to_region("us-west-2")
conn.create_stack("test_stack", template_body=dummy_template_json)
stack = conn.describe_stacks()[0]
stack.stack_id.should.contain(
"arn:aws:cloudformation:us-west-2:123456789:stack/test_stack/"
)
stack.stack_name.should.equal("test_stack")
stack.get_template().should.equal(
{

View File

@ -907,6 +907,13 @@ def test_creating_stacks_across_regions():
list(west1_cf.stacks.all()).should.have.length_of(1)
list(west2_cf.stacks.all()).should.have.length_of(1)
list(west1_cf.stacks.all())[0].stack_id.should.contain(
"arn:aws:cloudformation:us-west-1:123456789:stack/test_stack/"
)
list(west2_cf.stacks.all())[0].stack_id.should.contain(
"arn:aws:cloudformation:us-west-2:123456789:stack/test_stack/"
)
@mock_cloudformation
@mock_sns