Amazon CloudFront
API Reference (API Version 2010-11-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

PUT Distribution Config

Description

This action sets the configuration for a distribution. You use this when updating the configuration. You must follow a particular process when updating a distribution's configuration. For more information, go to Updating a Distribution's Configuration in the Amazon CloudFront Developer Guide.

To set a distribution's configuration, you do a PUT on the 2010-11-01/distribution/<distribution ID>/config resource. The request body must include an XML document with a DistributionConfig element. The new DistributionConfig configuration replaces the existing configuration; they are not merged. 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 erases the original CNAME alias and just adds the new one.

[Note]Note

You cannot change the following configuration elements: CustomOrigin (and child elements), DNSName (child of S3Origin), and CallerReference. If you try to change these configuration elements, CloudFront returns an IllegalUpdate error.

Requests

Syntax

PUT /2010-11-01/distribution/<distribution ID>/config HTTP/1.1
Host: cloudfront.amazonaws.com
If-Match: [value from ETag header in previous GET response]
Authorization: [AWS authentication string]
[Other required headers]			

<?xml version="1.0" encoding="UTF-8"?>
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
   <S3Origin>1
      <DNSName>mybucket.s3.amazonaws.com</DNSName>
      <OriginAccessIdentity>
      origin-access-identity/cloudfront/E127EXAMPLE51Z
      </OriginAccessIdentity>
   </S3Origin>   
   <CustomOrigin>2
      <DNSName>www.example.com</DNSName>
      <HTTPPort>80</HTTPPort>
      <HTTPSPort>443</HTTPSPort>
      <OriginProtocolPolicy>match-viewer</OriginProtocolPolicy>
   </CustomOrigin>
   <CallerReference>your unique caller reference</CallerReference>
   <CNAME>mysite.example.com</CNAME>
   <Comment>My comments</Comment>
   <Enabled>true</Enabled>
   <DefaultRootObject>index.html</DefaultRootObject>
   <Logging>
      <Bucket>mylogs.s3.amazonaws.com</Bucket>
      <Prefix>myprefix/</Prefix>
   </Logging>
   <TrustedSigners>
      <Self/>
      <AwsAccountNumber>111122223333</AwsAccountNumber>
      <AwsAccountNumber>444455556666</AwsAccountNumber>
   </TrustedSigners>
   <RequiredProtocols>
      <Protocol>https</Protocol>
   </RequiredProtocols>   
</DistributionConfig>

1

Use the S3Origin element only if you use an Amazon S3 origin for your distribution.

2

Use the CustomOrigin element only if you use a custom origin for your distribution. For more information about the CustomOrigin element and the S3Origin element, see DistributionConfig Complex Type.

Headers

The following table lists the special request header the action uses in addition to the common request headers all actions use (for more information, see Common REST Headers).

NameDescriptionRequired

If-Match

The value of the ETag header you received when retrieving the distribution's configuration. For example: E2QWRUHAPOMQZL

Type: String

Yes

Request Elements

Name Description Required

DistributionConfig

The distribution's configuration information. For more information, see DistributionConfig Complex Type.

Type: DistributionConfig complex type

Yes

Responses

Syntax

200 OK
ETag: [Updated ETag value, which can be used to do another PUT or to do a DELETE]
x-amz-request-id: [Request ID]

<?xml version="1.0" encoding="UTF-8"?>
<Distribution xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
   <Id>EDFDVBD632BHDS5</Id>
   <Status>Deployed</Status>
   <LastModifiedTime>2009-11-19T19:37:58Z</LastModifiedTime>
   <InProgressInvalidationBatches>1</InProgressInvalidationBatches>
   <DomainName>d604721fxaaqy9.cloudfront.net</DomaineName>
   <ActiveTrustedSigners>
         <Signer>
            <Self/>
            <KeyPairId>APKAI72T5DYBXEXAMPLE</KeyPairId>
         </Signer>
         <Signer>
            <AwsAccountNumber>111122223333</AwsAccountNumber>
            <KeyPairId>APKA9ONS7QCOWEXAMPLE</KeyPairId>
         </Signer>
   </ActiveTrustedSigners>
   <DistributionConfig>
      <S3Origin>1
         <DNSName>mybucket.s3.amazonaws.com</DNSName>
         <OriginAccessIdentity>
         origin-access-identity/cloudfront/E127EXAMPLE51Z
         </OriginAccessIdentity>
      </S3Origin>   
      <CustomOrigin>2
         <DNSName>www.example.com</DNSName>
         <HTTPPort>80</HTTPPort>
         <OriginProtocolPolicy>http-only</OriginProtocolPolicy>
      </CustomOrigin>
      <CallerReference>your unique caller reference</CallerReference>
      <CNAME>mysite.example.com</CNAME>
      <Comment>My comments</Comment>
      <Enabled>true</Enabled>
      <DefaultRootObject>index.html</DefaultRootObject>
      <Logging>
         <Bucket>mylogs.s3.amazonaws.com</Bucket>
         <Prefix>myprefix/</Prefix>
      </Logging>
      <TrustedSigners>
         <Self/>
         <AwsAccountNumber>111122223333</AwsAccountNumber>
         <AwsAccountNumber>444455556666</AwsAccountNumber>
      </TrustedSigners>
   </DistributionConfig>
   </Distribution>

1

The S3Origin element is returned only if you use an Amazon S3 origin for your distribution.

2

The CustomOrigin element is returned only if you use a custom origin for your distribution. For more information about the CustomOrigin element and the S3Origin element, see DistributionConfig Complex Type.

Headers

NameDescription

ETag

The current version of the configuration. For example: E2QWRUHAPOMQZL. For information about using the ETag header value, go to Deleting a Distribution in the Amazon CloudFront Developer Guide.

Type: String

Elements

NameDescription

Distribution

The distribution's information. For more information, see Distribution Complex Type.

Type: Distribution datatype

Special Errors

The following table lists the special errors returned in addition to the common errors all actions return (for more information, see Errors).

ErrorDescriptionHTTP Status Code

CNAMEAlreadyExists

One or more of the CNAMEs you provided are already associated with a different distribution.

409

IllegalUpdate

Origin and CallerReference cannot be updated.

400

InvalidIfMatchVersion

The If-Match version is missing or not valid for the distribution.

400

InvalidOriginAccessIdentity

The origin access identity is not valid or doesn't exist.

400

InvalidRequiredProtocol

This operation requires the HTTPS protocol. Ensure that you specify the HTTPS protocol in your request, or omit the RequiredProtocols element from your distribution configuration.

400

MissingBody

This operation requires a body. Ensure that the body is present and the Content-Type header is set.

400

NoSuchDistribution

The specified distribution does not exist.

404

PreconditionFailed

The precondition given in one or more of the request-header fields evaluated to false.

412

TooManyDistributionCNAMEs

Your request contains more CNAMEs than are allowed per distribution.

400

TooManyTrustedSigners

Your request contains more trusted signers than are allowed per distribution.

400

TrustedSignerDoesNotExist

One or more of your trusted signers do not exist.

400

Examples

The following example request updates the configuration for the EDFDVBD632BHDS5 distribution.

Sample Request

PUT /2010-11-01/distribution/EDFDVBD632BHDS5/config HTTP/1.1
Host: cloudfront.amazonaws.com
Authorization: AWS O39F6A430S6FJNPPGDR2:frJIUN8DYpKDtOLEXAMPLE=
Date: Thu, 19 Nov 2009 19:37:58 GMT
If-Match: E2QWRUHAPOMQZL
[Other required headers]

<?xml version="1.0" encoding="UTF-8"?>
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
      <S3Origin>1
         <DNSName>mybucket.s3.amazonaws.com</DNSName>
      </S3Origin>
      <CallerReference>20091130090000</CallerReference>
   <CNAME>beagles.com</CNAME>
   <Comment>A different comment</Comment>
   <Enabled>true</Enabled>
   <DefaultRootObject>index.html</DefaultRootObject>
   <Logging>
      <Bucket>mylogs.s3.amazonaws.com</Bucket>
      <Prefix>myprefix/</Prefix>
   </Logging>
   </DistributionConfig>

1

Use the S3Origin element only if you use an Amazon S3 origin for your distribution.

Sample Response

200 OK
ETag: E9LHASXUMDPRTF
x-amz-request-id: request_id
			
<?xml version="1.0" encoding="UTF-8"?>
<Distribution xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
   <Id>EDFDVBD632BHDS5</Id>
   <Status>InProgress</Status>
   <LastModifiedTime>2009-11-19T19:37:58Z</LastModifiedTime>
   <DomainName>d604721fxaaqy9.cloudfront.net</DomainName>
   <DistributionConfig>
      <S3Origin>1
         <DNSName>mybucket.s3.amazonaws.com</DNSName>
      </S3Origin>   
      <CallerReference>20091130090000</CallerReference>
      <CNAME>beagles.com</CNAME>
      <Comment>A different comment</Comment>
      <Enabled>true</Enabled>
      <Logging>
         <Bucket>mylogs.s3.amazonaws.com</Bucket>
         <Prefix>myprefix/</Prefix>
      </Logging>
   </DistributionConfig>
   </Distribution>

1

The S3Origin element is returned only if you use an Amazon S3 origin for your distribution.