Amazon CloudFront
API Reference (API Version 2014-11-06)
Did this page help you?  Yes | No |  Tell us about it...
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.

REST Requests

Amazon CloudFront REST requests are HTTPS requests, as defined by RFC 2616. For more information, go to http://www.ietf.org/rfc/rfc2616.txt. This section describes the structure of a CloudFront REST request. For detailed descriptions of the actions you can perform, go to the Amazon CloudFront API Reference.

A typical REST action consists of sending a single HTTPS request to CloudFront, and waiting for the HTTP response. Like any HTTP request, a REST request to CloudFront contains a request method, a URI, request headers, and sometimes a query string or request body. The response contains an HTTP status code, response headers, and sometimes a response body.

Request URI

The request URI always starts with a forward slash and then the version of the CloudFront API you use, for example, 2014-11-06. The remainder of the URI indicates the particular resource you want to act on. For example, following is the URI you use when creating a new distribution:

/2014-11-06/distribution

For more information about creating a distribution using the CloudFront API, go to POST Distribution in the Amazon CloudFront API Reference).

Request Headers

The following table lists the HTTP headers that CloudFront REST requests use.

Header NameDescriptionRequired

Authorization

The information required for request authentication. For more information, see Authenticating REST Requests.

Yes

Content-Length

Length of the message (without the headers) according to RFC 2616.

Condition: Required if the request body itself contains information (most toolkits add this header automatically).

Conditional

Content-Type

The content type of the resource. Example: text/plain.

Condition: Required for POST and PUT requests.

Conditional

Date

The date used to create the signature contained in the Authorization header. The format must be one of the full date formats specified in RFC 2616 section 3.1.1, for example, Wed, 05 Apr 2006 21:12:00 GMT. For more information, go to the RFC 2616 specification.

Condition: Required unless you provide the x-amz-date header. For more information about the request time stamp, see Request Time Stamp.

Conditional

Host

The host being requested. The value must be cloudfront.amazonaws.com

Condition: Required for HTTP 1.1. Most toolkits add this header automatically.

Conditional

x-amz-date

The date used to create the signature contained in the Authorization header. The format must be one of the full date formats specified in RFC 2616 section 3.1.1, for example, Wed, 05 Apr 2006 21:12:00 GMT. For more information, go to the RFC 2616 specification.

Condition: Required if you do not provide the Date header. For more information, see Request Time Stamp.

Conditional

Request Time Stamp

You must provide the time stamp in either the HTTP Date header or the AWS x-amz-date header (some HTTP client libraries don't let you set the Date header). When an x-amz-date header is present, the system ignores any Date header when authenticating the request.

The time stamp must be within 15 minutes of the AWS system time when the request is received. If it isn't, the request fails with the RequestExpired error code. This is to prevent replays of your requests by an adversary.

Request Body

Many of the CloudFront API actions require you to include XML in the body of the request. The XML conforms to the CloudFront schema. The topics in this guide that describe the API actions show the structure of the XML required in the request.

Example Request

The following example request creates a distribution in the CloudFront system.

POST /2014-11-06/distribution HTTP/1.1
Host: cloudfront.amazonaws.com
Authorization: [AWS authentication string]
Date: Thu, 17 May 2012 19:37:58 GMT
[Other required headers]
		
<?xml version="1.0" encoding="UTF-8"?>
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2014-11-06/">
   <CallerReference>example.com2012-04-11-5:09pm</CallerReference>
   <Aliases>
      ...
   </Aliases>
   <DefaultRootObject>index.html</DefaultRootObject>
   <Origins>
      ...
   </Origins>
   <CacheBehaviors>
      ...
   </CacheBehaviors>
   <Comment>example comment</Comment>
   <Logging>
      ...
   </Logging>
   <PriceClass>PriceClass_All</PriceClass>
   <Enabled>true</Enabled>
</DistributionConfig>