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...

POST Distribution

Description

This action creates a new distribution. You can create up to 100 per AWS account.

To create a new distribution, you do a POST on the 2010-11-01/distribution resource. The request body must include an XML document with a DistributionConfig element. The response echoes the DistributionConfig element and returns other metadata about the distribution. For more information about the parts of a distribution and creating distributions, see Working with Distributions in the Amazon CloudFront Developer Guide.

Requests

Syntax

POST /2010-11-01/distribution HTTP/1.1
Host: cloudfront.amazonaws.com
Authorization: AWS authentication string
Date: [time stamp]
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>
      <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>
</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 request must include the headers required in all CloudFront requests. For more information, see Common REST Headers.

Elements

Name Description Required

DistributionConfig

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

Type: DistributionConfig complex type

Default: None

Yes

Responses

Syntax

201 Created
Location: [URI of new distribution]
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>
         <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>
   </DistributionConfig>
</Distribution>

1

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

2

CloudFront returns the CustomOrigin element only if you use a custom origin for your distribution.

Headers

NameDescription

Location

The fully qualified URI of the new distribution resource just created. For example: https://cloudfront.amazonaws.com/2010-11-01/distribution/EDFDVBD632BHDS5

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

DistributionAlreadyExists

The caller reference you attempted to create the distribution with is associated with another distribution.

409

InvalidOrigin

The Amazon S3 origin server specified does not refer to a valid Amazon S3 bucket.

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

TooManyDistributionCNAMEs

Your request contains more CNAMEs than are allowed per distribution.

400

TooManyDistributions

Processing your request would cause you to exceed the maximum number of distributions allowed.

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 creates a new public content distribution that corresponds to the bucket mybucket.s3.amazonaws.com. The request includes a CNAME alias, and the request enables logging.

Sample Request

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

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

Sample Response

201 Created
Location: https://cloudfront.amazonaws.com/2010-11-01/distribution/EDFDVBD632BHDS5
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>
         <DNSName>mybucket.s3.amazonaws.com</DNSName>
      </S3Origin>
      <CallerReference>20091130090000</CallerReference>
      <CNAME>beagles.com</CNAME>
      <Comment>My comments</Comment>
      <Enabled>true</Enabled>
      <Logging>
         <Bucket>mylogs.s3.amazonaws.com</Bucket>
         <Prefix>myprefix/</Prefix>
      </Logging>
    </DistributionConfig>
</Distribution>

Sample Request

The following example request creates a public content distribution, but without a CNAME alias, and without logging enabled. Only include a CNAME element if you have a CNAME you want to specify. Don't include an empty CNAME element. If you do, CloudFront returns a MalformedXML error.

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

<?xml version="1.0" encoding="UTF-8"?>
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
   <S3Origin>
      <DNSName>mybucket.s3.amazonaws.com</DNSName>
   </S3Origin>
   <CallerReference>20091130090000</CallerReference>
   <Comment>My comments</Comment>
   <Enabled>true</Enabled>
</DistributionConfig>