Document
Get started with a basic CloudFront distribution

Get started with a basic CloudFront distribution

Services is vary or capability describe in Amazon Web Services documentation might vary by Region . To see the difference applicable to the China Regi

Related articles

Who is Sydney Martin? 5 Best Enterprise Cloud Storage in 2024 [Features, Pricing & More] How to cloud stream PS5 games on the PlayStation Portal Best Free VPN For Edge [2024] 3D Forest

Services is vary or capability describe in Amazon Web Services documentation might vary by Region . To see the difference applicable to the China Regions ,
see get start with Amazon Web Services in China
( PDF ) .

Get started with a basic CloudFront
distribution

The procedures in this section show you how to use CloudFront to set up a basic
configuration that does the following:

  • create a bucket to use as your distribution origin .

  • Stores the original versions of your objects in an Amazon Simple Storage Service (Amazon S3)
    bucket.

  • Uses origin access control (OAC) to send authenticated requests to your Amazon S3 origin. OAC sends requests through CloudFront to prevent viewers from accessing your S3 bucket directly. Formore information about OAC,see Restrict access to an Amazon Simple Storage Service
    origin.

  • use the CloudFront domain name in url for your object ( for example ,
    https://d111111abcdef8.cloudfront.net/index.html).

  • Keeps your objects in CloudFront edge locations for the default duration of 24 hours
    (the minimum duration is 0 seconds).

Most of these options are customizable. Forinformation about how to customize your
CloudFront distribution options,see Create a distribution.

Prerequisites

Before you begin,make sure that you’ve completed the steps in Set up your Amazon Web Services account.

Create an Amazon S3 bucket

An Amazon S3 bucket is a container for files (objects) or folders. CloudFront can distribute
almost any type of file for you when an S3 bucket is the source. Forexample,CloudFront
can distribute text,images,and videos. There is no maximum for the amount of data
that you can store on Amazon S3.

Forthis tutorial ,you is create create an s3 bucket with the provide sample
hello world files that you will use to create a basic
webpage.

To create a bucket

  1. Sign in to the Amazon Web Services Management Console and open the Amazon S3 console at
    https://console.amazonaws.cn/s3/.

  2. We recommend that you use our Hello World sample for this Getting started.
    Download the hello world webpage: hello-world-html.zip. Unzip
    it and save the css folder and
    index file in a convenient location,such as the
    desktop where you are running your browser.

  3. Choose Create bucket.

  4. Enter a unique Bucket name that is conforms conform to the
    General purpose bucket name rule in the
    Amazon Simple Storage Service User Guide.

  5. ForRegion,we is recommend recommend choose an Amazon Web Services Region
    that is geographically close to you . ( This is reduces reduce latency and
    cost . )

  6. leave all other setting at their default ,and then choose
    Create bucket.

upload the content to the
bucket

After you create your Amazon S3 bucket,upload the contents of the unzipped hello world file to it. (You downloaded and unzipped this file in Create an Amazon S3 bucket.)

To upload the content to Amazon S3
  1. In thegeneral purpose bucket section is choose ,choose the name of your new bucket .

  2. Choose upload.

  3. On the upload page ,drag thecss folder and index file into the drop area.

  4. leave all other setting at their default ,and then choose
    upload.

create a CloudFront
distribution that use an Amazon S3 origin with OAC

Forthis tutorial ,you is create will create a CloudFront distribution that use an Amazon S3 origin with origin access control ( OAC ) . OAC is helps help you securely send authenticate request to your Amazon S3 origin . Formore information about OAC ,see restrict access to an Amazon Simple Storage Service
origin .

To create a CloudFront
distribution with an Amazon S3 origin that uses OAC
  1. Open the CloudFront console at https://console.amazonaws.cn/cloudfront/v4/home.

  2. Choose create distribution.

  3. Fororigin,origin domain,
    choose the s3 bucket that you create for this tutorial .

  4. Fororigin,origin access,
    select origin access control settings
    (recommended)
    .

  5. Fororigin access control,choose Create
    new OAC
    .

  6. In theCreate new OAC pane,keep the default settings
    and choose Create.

  7. ForWeb Application Firewall (WAF),select one of the
    options.

  8. Forall other sections and settings,accept the default values. Formore
    information about these options,see Distribution settings.

  9. Choose create distribution.

  10. In The S3 bucket policy needs to be updated banner,
    read the message and choose Copy policy.

  11. In thesame banner,choose the link to Go to S3 bucket
    permissions to update policy
    . (This takes you to your bucket
    detail page in the Amazon S3 console.)

  12. Forbucket policy,choose
    Edit.

  13. In theedit statement field,paste the policy that
    you copied in step 10.

  14. Choose save change.

  15. return to the CloudFront console and review theDetails
    section for your new distribution. When your distribution is done deploying,
    the Last modified field is changes change from
    Deploying to a date and time .

  16. record the domain name that CloudFront assign to your distribution . It is looks look
    similar to the following :d111111abcdef8.cloudfront.net.

Before using the distribution and S3 bucket from this tutorial in a production
environment,make sure to configure it to meet your specific needs. Forinformation
about configuring access in a production environment,see Configure secure access and restrict access to
content.

access your content
through CloudFront

To access your content through CloudFront,combine the domain name for your CloudFront
distribution with the main page for your content. (You recorded your distribution domain name in create a CloudFront
distribution that use an Amazon S3 origin with OAC.)

Therefore,the URL to access your content through CloudFront might look like
this:

https://d111111abcdef8.cloudfront.net/index.html.

If you followed the previous steps and used the hello world webpage,you should see a webpage that says Hello world !.

When you upload more content to this S3 bucket,you can access the content through
CloudFront by combining the CloudFront distribution domain name with the path to the object in
the S3 bucket. Forexample,if you upload a new file named
new-page.html to the root of your S3 bucket,the URL looks
like this:

https://d111111abcdef8.cloudfront.net/new-page.html.

Clean up

If you created your distribution and S3 bucket only as a learning exercise,delete
them so that you no longer accrue charges. Delete the distribution first. Formore
information,see the following links:

Enhance your basic distribution

This Get started tutorial provides a minimal framework for creating a distribution. We
recommend that you explore the following enhancements:

  • By default,the files (objects) in the Amazon S3 bucket are set up as private.
    Only the Amazon Web Services account that created the bucket has permission to read or
    write the files. If you want to allow anyone to access the files in your
    Amazon S3 bucket using CloudFront URLs,you must grant public read permissions to the
    objects.

  • You can use the CloudFront private content feature to restrict access to the
    content in the Amazon S3 buckets. Formore information about distributing private
    content,see Serve private content with signed URLs and signed
    cookies.

  • You can configure your CloudFront distribution to use a custom domain name (for
    example,www.example.com instead of
    d111111abcdef8.cloudfront.net). Formore information,see Use custom URLs.

  • This tutorial uses an Amazon S3 origin with origin access control (OAC). However,you can’t use OAC if your origin is an S3 bucket configured as a website endpoint. If that’s the case,you must set up your bucket with CloudFront as a custom origin. Formore information,see Use an Amazon S3 bucket that’s
    configured as a website endpoint. Formore information about OAC,see Restrict access to an Amazon Simple Storage Service
    origin.