Fixed Failures in CloudFormation Provisioning of S3 Buckets When Stack has Long Name... (#3169)
* Fixed defect with CloudFormation provisioning of S3 buckets occuring when stack has a long name, resulting in the default S3 bucket name's length exceeding its 63 char limit. * PR 3169 July 23, 2020 2:57a ET comment: added additional asserts to assure provisioned bucket's name complies. Fixed bug in my earlier change that could produce default bucket names with illegal upper-case characters in it. Co-authored-by: Joseph Weitekamp <jweite@amazon.com>
This commit is contained in:
parent
ff1f565142
commit
736c8b77ce
2 changed files with 31 additions and 0 deletions
|
|
@ -654,6 +654,31 @@ def test_boto3_create_stack():
|
|||
)
|
||||
|
||||
|
||||
@mock_cloudformation
|
||||
def test_boto3_create_stack_s3_long_name():
|
||||
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
|
||||
|
||||
stack_name = "MyLongStackName01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012"
|
||||
|
||||
template = '{"Resources":{"HelloBucket":{"Type":"AWS::S3::Bucket"}}}'
|
||||
|
||||
cf_conn.create_stack(StackName=stack_name, TemplateBody=template)
|
||||
|
||||
cf_conn.get_template(StackName=stack_name)["TemplateBody"].should.equal(
|
||||
json.loads(template, object_pairs_hook=OrderedDict)
|
||||
)
|
||||
provisioned_resource = cf_conn.list_stack_resources(StackName=stack_name)[
|
||||
"StackResourceSummaries"
|
||||
][0]
|
||||
provisioned_bucket_name = provisioned_resource["PhysicalResourceId"]
|
||||
len(provisioned_bucket_name).should.be.lower_than(64)
|
||||
logical_name_lower_case = provisioned_resource["LogicalResourceId"].lower()
|
||||
bucket_name_stack_name_prefix = provisioned_bucket_name[
|
||||
: provisioned_bucket_name.index("-" + logical_name_lower_case)
|
||||
]
|
||||
stack_name.lower().should.contain(bucket_name_stack_name_prefix)
|
||||
|
||||
|
||||
@mock_cloudformation
|
||||
def test_boto3_create_stack_with_yaml():
|
||||
cf_conn = boto3.client("cloudformation", region_name="us-east-1")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue