aws-samples / amazon-cloudfront-secure-static-site

Create a secure static website with CloudFront for your registered domain.
Apache License 2.0
389 stars 140 forks source link

Use Stack ID for OriginAccessControl.Name property #69

Closed ConnorKirk closed 1 year ago

ConnorKirk commented 1 year ago

Issue #, if available: Fixes #67 and #66

Description of changes:

The template fails to deploy when the stack name is longer than 64 characters. The OriginAccessControlConfig resource fails to create, with a generic InvalidRequest error. The Name property has. a max length of 64 characters.

The OriginAccessControlConfig.Name property was set to !Sub oac-${AWS::StackName}-${AWS::Region}'. For sufficiently long stack names (including the default stack name), this triggered the bug described above.

OriginAccessControlConfigresources must have a unique name across all regions for an account. To ensure this, theName` property was derived from both the StackName and Region. The max length of a stack name is 128 characters. This is longer than the 64 characters allowed by the OACConfig Name property.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.