Search code examples
amazon-web-servicesamazon-cloudfrontaws-cloudformation

How to provide Alternate Domain Names (CNAMEs) to the CloudFront distribution using CloudFormation?


I have tried:

"Aliases": ["www.samplewebsite.com","samplewebsite.com"]

But I am getting this error:

Property validation failure: [Encountered unsupported properties in {/DistributionConfig/Origins/0}: [Aliases]]


Solution

  • Ok, so the problem seems to be with the JSON object structure that you are using for creating the CloudFront distribution.

    In oder to add the alternate CNAME to your Cloudfront distribution, you need to add the key "Aliases" under the "DistributionConfig" object and not under "DistributionConfig/Origins".

    So basically the property "Aliases" is defined as child object of "DistributionConfig".

    Hope this helps.