download free 30 days trial version buy bucket explorer
Documentation  Download  Purchase  Support  FAQs   Forum   ScreenShots & Demos

CloudFront - How to Update Distributions with Multiple Origin Servers (GET/PUT Distribution with Multiple Origins)?

To deliver your content to your end users via CloudFront, you will need to create CloudFront Distributions . Depending on the type of content you are going to deliver, you can create two types of Distributions- Download Distribution (for HTTP or HTTPS delivery) or Streaming Distribution (for RTMP). Each Distribution will have a unique domain name, that you can refer it with from your web applications.

CloudFront allows you to create distribution for multi origin, origin running from inside of AWS as well as from outside of AWS that helps you deliver personalized and dynamic web content much faster. You can convert single origin distribution into multi origin distribution by updating distribution. You do not need to create multiple distributions and manage multiple domain names on your web site.

You can Update Distributions with Multiple Origin Servers by sending the PUT Request either using Amazon CloudFront API PUT Distribution Config with Multiple Origins OR using Bucket Explorer User Interface. To use Amazon CloudFront API, you will need to write your own software program, however, if you do not want to write your program, you can use Bucket Explorer User Interface to Update Distributions with Multiple Origin Servers using mouse clicks.

The below two sections describe how you can Update Distributions using the PUT request in your code or using Bucket Explorer.

1. Update Multi Origin Download Distribution Using REST API

Steps :

  1. Submit a GET Distribution Config request to get the current configuration and the Etag header for the distribution.
  2. Update the XML document that was returned in the response to GET Streaming Distribution Config request with the desired changes in origins.
  3. Submit a PUT Distribution Config request to update the distribution.

Syntax: GET Distribution Config


GET /2013-05-12/distribution/ distribution ID /config HTTP/1.1
Host: cloudfront.amazonaws.com
Authorization: AWS authentication string
Date: time stamp
Other required headers
 

Syntax: PUT Distribution Config


PUT /2013-05-12/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/2013-05-12/">
<CallerReference> unique description for this
distribution config </CallerReference>
<Aliases>
<Quantity> number of CNAME aliases </Quantity>
<!-- Optional. Omit when Quantity = 0. -->
<Items>
<CNAME> CNAME alias </CNAME>
</Items>
</Aliases>
<DefaultRootObject> URL for default root object </DefaultRootObject>
<Origins>
<Quantity> number of origins </Quantity>
<Items>
<Origin>
<Id> unique identifier for this origin </Id>
<DomainName> domain name of origin </DomainName>
<!-- Include the S3OriginConfig element only if
you use an Amazon S3 origin for your distribution. -->
<S3OriginConfig>
<OriginAccessIdentity>origin-access-identity/
cloudfront/ ID </OriginAccessIdentity>
</S3OriginConfig>
<!-- Include the CustomOriginConfig element only if
you use a custom origin for your distribution. -->
<CustomOriginConfig>
<HTTPPort> HTTP port that the custom origin
listens on </HTTPPort>
<HTTPSPort> HTTPS port that the custom origin
listens on </HTTPSPort>
<OriginProtocolPolicy>http-only |
match-viewer</OriginProtocolPolicy>
</CustomOriginConfig>
</Origin>
</Items>
</Origins>
<DefaultCacheBehavior>
<TargetOriginId> ID of the origin that the default cache behavior
applies to </TargetOriginId>
<ForwardedValues>
<QueryString>true | false</QueryString>
<Cookies>
<Forward>all | whitelist | none</Forward>
<!-- Required when Forward = whitelist,
omitted otherwise. -->
<WhitelistedNames>
<Quantity> number of cookie names to
forward to origin </Quantity>
<Items>
<Name> name of a cookie to forward to
the origin </Name>
</Items>
</WhitelistedNames>
</Cookies>
</ForwardedValues>
<TrustedSigners>
<Enabled>true | false</Enabled>
<Quantity> number of trusted signers </Quantity>
<!-- Optional. Omit when Quantity = 0. -->
<Items>
<AwsAccountNumber>self | AWS account that can create
signed URLs </AwsAccountNumber>
</Items>
</TrustedSigners>
<ViewerProtocolPolicy>allow-all |
https-only</ViewerProtocolPolicy>
<MinTTL> minimum TTL in seconds </MinTTL>
</DefaultCacheBehavior>
<CacheBehaviors>
<Quantity> number of cache behaviors </Quantity>
<!-- Optional. Omit when Quantity = 0. -->
<Items>
<CacheBehavior>
<PathPattern> pattern that specifies files that this
cache behavior applies to </PathPattern>
<TargetOriginId> ID of the origin that this cache behavior
applies to </TargetOriginId>
<ForwardedValues>
<QueryString>true | false</QueryString>
<Cookies>
<Forward>all | whitelist | none</Forward>
<!-- Required when Forward = whitelist,
omitted otherwise. -->
<WhitelistedNames>
<Quantity> number of cookie names to forward
to origin </Quantity>
<Items>
<Name> name of a cookie to forward to
the origin </Name>
</Items>
</WhitelistedNames>
</Cookies>
</ForwardedValues>
<TrustedSigners>
<Enabled>true | false</Enabled>
<Quantity> number of trusted signers </Quantity>
<!-- Optional. Omit when Quantity = 0. -->
<Items>
<AwsAccountNumber>self | AWS account that can create
signed URLs </AwsAccountNumber>
</Items>
</TrustedSigners>
<ViewerProtocolPolicy>allow-all |
https-only</ViewerProtocolPolicy>
<MinTTL> minimum TTL in seconds for files
specified by PathPattern </MinTTL>
</CacheBehavior>
</Items>
</CacheBehaviors>
<Comment> comment about the distribution </Comment>
<Logging>
<Enabled>true | false</Enabled>
<IncludeCookies>true | false</IncludeCookies>
<Bucket> Amazon S3 bucket to save logs in </Bucket>
<Prefix> prefix for log filenames </Prefix>
</Logging>
<ViewerCertificate>
<IAMCertificateId> IAM certificate ID </IAMCertificateId> |
<CloudFrontDefaultCertificate>true</CloudFrontDefaultCertificate>
</ViewerCertificate>
<PriceClass> maximum price class for the distribution </PriceClass>
<Enabled>true | false</Enabled>
</DistributionConfig>
 

2. Steps for Updating Multi Origin download distribution using Bucket Explorer:

  1. Run Bucket Explorer.
  2. Choose "Distribution - List Distribution" icon from Bucket table toolbar or you can do the same by selecting "Manage Distribution" option from right click menu option of any bucket.
  3. It displays a "Distribution" window with list of already created distributions.
  4. Select desired download distribution to update and click on Update button.
  5. It will open panel to update Download distribution.
  6. Make desired update in your distribution and click on Update button.