Updating a Distribution's Configuration

You can update a distribution's configuration at any time. This section describes the process you must use (regardless of the type of distribution: basic or streaming). The only parts of the distribution's configuration you can update are the CNAMEs, the comments, and whether the distribution is enabled. For more information about the contents of a basic distribution's configuration, go to DistributionConfig Complex Type in the Amazon CloudFront API Reference.

[Important]Important

When you update a distribution's configuration, you replace the entire configuration object with a new one; you don't add to the existing configuration. This distinction is important to remember when adding an additional CNAME alias to a distribution that already has one. Make sure to include the original CNAME alias in the DistributionConfig object, or else your update will erase the original CNAME alias and just add the new one.

When you try to update a distribution's configuration, another authorized person in your company could be trying to do the same thing. The following figure and table describe how to update the distribution to avoid any conflicts.

Basic flow for updating a distribution

Process for Updating a Distribution's Configuration

1

You send a request to retrieve the distribution's current configuration information.

You can get either the distribution's general information (go to GET Distribution, or specifically its configuration (go to GET Distribution Config).

2

CloudFront responds with the distribution's current information (in the form of an XML document) and the HTTP ETag header associated with the distribution's current information (e.g., E2QWRUHAPOMQZL). The same ETag is returned whether you requested the general distribution information or specifically the configuration.

If you requested the configuration, you can just update that same XML document you received with the changes you want to make to the distribution's configuration.

3

You send a request to update the distribution's configuration information. In the request, you include the updated XML document, and the HTTP If-Match header set to the value of the ETag header you received in task 2.

For information about updating a basic distribution's configuration object, go to PUT Distribution Config in the Amazon CloudFront API Reference.

4

AWS confirms that the version number you sent in the If-Match header matches the current version of the configuration information.

If it does, your request is processed.

If it does not, this means that someone else has modified the configuration since you retrieved the information earlier. In this case, CloudFront returns a PreconditionFailed error (HTTP status code 412). You should then repeat tasks 1-3. In task 2 you'll get a different value for the ETag header than you did the first time, and you must provide that new value in task 3.