Contact Us
Thought Leadership

Creating a simple CloudFront Distribution

By Jose Angel Navarro Machuca, Cloud Engineer at IO Connect Services
December 21, 2020

Introduction

This article describes how to create and use a simple CloudFront Distribution using the AWS console, taking advantage of AWS edge locations.

Objective

Create a CloudFront Distribution using an Amazon S3 bucket as the origin of Amazon Web Services (AWS)

Pre-requisite

  • You will need to get an account at AWS.
  • Basic knowledge of AWS services.

Steps to create a CloudFront Distribution

1. Upload your content to S3 and grant object permissions

For CloudFront to distribute your content, you need to store it in an S3 bucket. You can either create a new bucket or use an existing one. In this article, we will be creating a new bucket.

In AWS Console, select S3 service, in here click “Create bucket.” On this page, you need to provide some configurations:

  • Bucket name: write down a name for your bucket, the bucket name must be unique and must not contain spaces or uppercase letters.
  • Region: select the region in which the bucket will be created.
  • Block all public access: clear the checkbox, so that CloudFront URLs can serve content from the bucket (click the checkbox that you acknowledge that the current settings might result in this bucket and objects within becoming public)

Finally, create the bucket.

Open your newly created bucket and upload the content that you want to be distributed by CloudFront. In this guide, we will be uploading an image. Click on “Upload” then add the files that you want to upload and click “next.”

On the next screen, change the Manage public permissions to “Grant public read access to this object(s)” and click upload.

2. Create a CloudFront Distribution

In the console, open CloudFront service and click on “Create distribution.”

On the Select, a delivery method for your content screen, click on “Get Started” under the Web category.

On the Create Distribution page, you need to configure some settings. If you want to know more about each setting, you can click the “i” button for detailed information.

Origin Settings

  • Origin Domain Name: choose the S3 bucket we created before.
  • Origin Path: Leave it blank. (This is for when you want CloudFront to request your content from a directory in your S3 bucket).
  • Origin ID: Leave it blank. (This is to enter a description for the origin).
  • Origin Custom Headers: Leave it blank (This is for custom header keys and values).

Default Cache Behavior settings.

  • Path Pattern: Default (*).
  • Viewer Protocol Policy: HTTP and HTTPS.
  • Allowed HTTP Methods: GET, HEAD.
  • Cached HTTP Methods: GET, HEAD (Cached by default).
  • Object Caching: Use Origin Cache Headers.
  • Forward Cookies: None (Improves Caching).
  • Query String Forwarding and Caching: None (Improves Caching).
  • Smooth Streaming: No
  • Restrict Viewer Access (Use Signed URL or Signed Cookies): No
  • Compress Objects Automatically: No

Distribution Settings.

  • Price Class: Use All Edge Locations (Best Performance).
  • AWS WAF Web ACL: None
  • Alternate Domain Names (CNAMEs): Leave it blank.
  • SSL Certificate: Default CloudFront Certificate.
  • Supported HTTP Versions: HTTP/2, HTTP/1.1, HTTP/1.0
  • Default Root Object: Leave it blank.
  • Logging: Off
  • Enable IPv6: Check the box.
  • Comment: Leave it blank.
  • Distribution State: Enabled.

Finally, click on “Create Distribution.” You will be redirected to the Distribution screen, and you will see your distribution being created with the status of “In Progress.” It will take around 20 minutes to be completed when it does; the status will change to “Deployed.”

<html>
<head>CloudFront Test</head>
<body>
<p>Text Content that you want to share. </p>
<p><img src=https://<domain name>/<object name> alt=”CloudFront test image”/>
</body>
</html>

You can grab the Domain Name from the list of your Distributions deployed (see picture above), and the object name is the name of the file that resides in your S3 bucket (for example ioconnectservices.jpg).

And simply open your HTML file in a browser. You should see something like this.

Conclusion

In this article, we showed how to create a CloudFront Distribution in AWS, which is very useful when you want to deliver your content in an easy and fast way with low latency by caching your content in different Amazon Edge Locations around the globe.

Related Insights

We are results-driven with a focus on providing customer service excellence

IO Connect Services is here to help you by offering high-quality cloud technology solutions.
Connect with us
®2024 IO Connect Services
Privacy PolicyCookie Policy
magnifiercrossmenuchevron-down
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram