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

CloudFront - How to Update Distributions with Custom Origins (GET Distribution and PUT Distribution with Custom Origin details)?

CloudFront is an Amazon Web Service, used to deliver content with low latency as well as high data transfer speed. CloudFront allows you to create Distribution for S3 Origin as well as Non S3 Origin Server (outside of Amazon S3), which means you can create distribution for S3 Bucket as well as other registered domains. A Distribution, which is created for Non S3 Origin, is known as Custom Origin Distribution. CloudFront also allows you to create multi origin distribution, which can be a combination of S3 and Non S3 Origin Servers. Once you have created any distribution, it can be updated later.

To Update CloudFront Custom Distribution you have one of two options:
  1. Update Custom Origin Distribution using CloudFront PUT Distribution REST API - If you are programmer, you can write your own source code to Update Custom Origin Distribution using GET Distribution Config and PUT Distribution Config APIs.
  2. Update Custom Origin Distribution using Bucket Explorer If you do not want to write code, you can do this with Bucket Explorer with few mouse clicks.

A. Update Distribution for Custom Origin Using REST API

Steps to be followed to Update Distribution for Custom Origin -

  1. Submit a GET Distribution Config request to get the information of selected distribution.
  2. Make an update in the XML document that was returned in response to GET Distribution Config request with the changes in custom origin details.
  3. Next create PUT Distribution Config request to update the distribution

GET Distribution Config Request


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
 

PUT Distribution Config Request


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>
 

B. Update Distribution for Custom Origin Using Bucket Explorer

  1. Open the Distribuion panel.
  2. Select Custom Origin Distribution from list distribution panel.
  3. To update a custom origin, select it then click on Update button situated at listing distribution panel.
  4. Make changes as you want like HTTPS/HTTP and Policy.
  5. Click on Update. It takes time to get deployed.