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

CloudFront - How to Create Public Distribution (POST Distribution)?

CloudFront is an Amazon Web Service for content delivery, which is used to increase the speed of distribution of your data from Origin (Origin will be either an Amazon S3 Bucket or an HTTP server). The distribution content may be static or dynamic. Distribution is a link between an Amazon S3 bucket (the origin server) and a domain name (which Amazon CloudFront automatically assigns) to make Amazon CloudFront recognize your objects. Distribution serves its data using HTTP as well as HTTPS. You can distribute files like css, jpg, html etc. using CloudFront Distributions.

Create Public Download Distribution:

Once you've stored your objects in your origin server, you need to create a distribution to distribute those using CloudFront. To create a distribution, you need to set a configuration in which you specify Bucket name, CNAME(s), Comment, Enable/Disable, Cache Behaviors, etc.

You can send a POST HTTP Request to Create Public Download Distribution by using one of the two methods:
  1. Create Public Download Distribution using Amazon CloudFront REST API POST Distribution - You will need to write your own code to Create Public Download Distribution. If you want to use SOAP API instead, you can read more on AWS Documentation. On this site, we will be referring to REST API.
  2. Create Public Download Distribution using Bucket Explorer - If, however, you are not a programmer and would not like to write any software program, you can use Bucket Explorer User Interface to Create Public Download Distribution with mouse clicks.

1. Create Public Download Distribution using AWS REST API POST Distribution:

You can perform Create Public Distribution operations by using Amazon CloudFront supported REST API in your application code.

To create a new Public distribution, you need to send a POST request on the 2013-05-12/distribution resource. In this the request, body must include an XML document with a DistributionConfig element. The DistributionConfig element describes a distribution's configuration information.

Syntax:

POST /2013-05-12/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/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. Create Public Download Distribution using Bucket Explorer:

You can perform the same Create Public Download Distribution operations using Bucket Explorer without writing a single line of code.

Steps for Creating Public Download Distribution using Bucket Explorer:

  1. Run Bucket Explorer.
  2. Choose "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. To create new distribution, choose "New" icon from toolbar of Distribution window.
  5. It opens new window to create distribution. Now you need to set configuration for public distribution.
  6. Distribution Type :
    Select the distribution type "Download Distribution"
  1. General Distribution Details
    • Default Root Object [Optional] : Enter Default Root Object if you want to make any file default.
    • CNAME [Optional]: Enter CNAME Entry if you want to add. You can enter up to 10 CName entries here.
    • Price Class : Select Price Class - Price Class All, Price Class 200, Price Class 100 as per your choice .
    • Logging [Optional]: You can also add Logging setting details here, where you want to get created distribution logging with file having prefix so and so. You can mention Bucket Name and Log File Name Prefix here.
    • Comments [Optional]: Enter comment about this distribution .
    • After entering all required entries, press Next Button.
  2. Origin Details

    • Here you will find two tabs 1. S3 Origin 2. Non-S3 (Custom) Origin, Select S3 Origin tab
    • Now you have to select Bucket as S3 Origin
    • Do not make any selection for Origin Access Identity Details – It is Only for Private Download Distribution.
    • Now Press Add Button
    • After entering all required entries, press Next Button.
  3. Cache Behavior Details :
    • Path Pattern : You can add Path pattern for cache behavior (Not Applicable for Default Cache Behavior)
    • Targeted Origin ID : To associate the cache behavior with origin, you have to select the target origin id or select any bucket. Both are associated with each other.
    • Trusted Signer : Keep trusted signer disabled. (Unchecked the Trusted Signer Check-box)
    • Viewer Protocol Policy : Select Allow All or Https Only.
    • Query String : You can set query string option enabled or disabled as per your requirements.
    • Min TTL : You can set min TTL for distribution from 0.0 to ~3,153,600,000 seconds. Default setting is 3600s.
    • Default : If Origin table have one entry then here Cache Behavior will have to set default.
  4. After entering all required entries, press Create Button.