Search code examples
amazon-web-servicesamazon-cloudfront

In AWS CloudFront API, which call do I use to add a CNAME to a distribution?


In the GUI, I can add CNAMEs to the distribution for future use in Route53, what is the appropriate API call for that?


Solution

  • The CloudFront API uses kind of a monolithic REST-like model -- there's no API method to simply modify this one thing.

    Instead, you use PUT /2017-03-25/distribution/Id/config HTTP/1.1 and replace essentially the entire distribution configuration with a new configuration, which consists of the current distribution config, as fetched from the API, plus any changes.

    Distribution alternate domain names (unfortunately they are inaccurately referred to as CNAMEs) are in the <Aliases> block of the XML.

    http://docs.aws.amazon.com/cloudfront/latest/APIReference/API_UpdateDistribution.html