Forum

Introduction to Ama...
 
Notifications
Clear all

Introduction to Amazon CloudFront

1 Posts
1 Users
0 Reactions
3,273 Views
Posts: 108
Topic starter
(@taichi)
Member
Joined: 5 years ago

Introduction to Amazon CloudFront

This lab introduces you to AWS CloudFront, a content delivery web service. In this lab you will create an Amazon CloudFront distribution that will use a CloudFront domain name in the url to distribute a publicly accessible image file stored in an Amazon S3 bucket.

 

 
 

Introduction to Amazon CloudFront

 

SPL-85 - Version 1.0.10

© 2020 Amazon Web Services, Inc. and its affiliates. All rights reserved. This work may not be reproduced or redistributed, in whole or in part, without prior written permission from Amazon Web Services, Inc. Commercial copying, lending, or selling is prohibited.

Errors or corrections? Email us at [email protected].

Other questions? Contact us at  https://aws.amazon.com/contact-us/aws-training/

Overview

This guide introduces you to Amazon CloudFront. In this lab you will create an Amazon CloudFront distribution that will use a CloudFront domain name in the url to distribute a publicly accessible image file stored in an Amazon S3 bucket.

Topics covered

By the end of this lab, you will be able to:

  • Create a new Amazon CloudFront distribution
  • Use your Amazon CloudFront distribution to serve an image file
  • Delete your Amazon CloudFront distribution when it is no longer required

Amazon CloudFront

Amazon CloudFront is a content delivery web service. It integrates with other Amazon Web Services products to give developers and businesses an easy way to distribute content to end users with low latency, high data transfer speeds, and no minimum usage commitments.

  •  

Task 1: Store a Publicly Accessible Image File in an Amazon S3 Bucket

In this task, you will store the file that you wish to distribute using Amazon CloudFront in a publicly accessible location. You will store the image file in a publically accessible Amazon S3 bucket.

  1. In the AWS Management Console, on the Services menu, click S3.

  2. Click Create bucket and then configure:

  • Bucket name: 
  • Replace BUCKET with a random number
  • Click Create bucket

Note: If you receive an error saying that your bucket name is not available, try a different bucket name. For your bucket to work with CloudFront, the name must conform to DNS naming requirements. For more information, go to Bucket Restrictions and Limitations in the Amazon Simple Storage Service Developer Guide.

  1. Click S3 bucket you created.

  2. Click the Permissions tab. The Block public access button is highlighted. If it is not, click it.

  3. Click Edit to change the settings.

  4. Deselect the Block all public access option, and then leave all other options deselected.

 Notice all of the individual options remain deselected. When deselecting all public access, you must then select the individual options that apply to your situation and security objectives. In a production environment, it is recommended to use the least permissive settings possible.

  1. Click Save

A dialogue box opens asking you to confirm your changes.

  1. Type  in the field, and then click Confirm

  2. Click Overview tab.

  3. Click  Upload

  4. Click Add files

  5. Select a file that you would like to upload.

If you don’t have a file prepared, visit a favorite website in your browser and download an image from the website to your desktop. Then choose that file for this step.

  1. Click Next then configure:
  • Under Manage public permissions, select Grant public read access to this object(s)
  • Click Upload
  1. Copy the name of your file to your text editor for later use.

e.g. The name of your file could be myimage.png

  1. Click the file that you uploaded.

  2. Under S3 Object URL, copy the link to your clipboard.

  3. Paste the link in a new browser tab, then press Enter.

This will display your image. It also proves that your content is publicly accessible. However, this is not the URL you will use when you are ready to distribute your content.

Task 2: Create an Amazon CloudFront Web Distribution

In this task, you will create an Amazon CloudFront web distribution that distributes the file stored in the publicly accessible Amazon S3 bucket.

  1. In the AWS Management Console, on the Services menu, click CloudFront.

  2. Click Create Distribution

  3. On the Select a delivery method for your content page, in the Web section, click Get Started then configure:

  • Origin Domain Name: Select the S3 bucket you created
  • Scroll to the bottom of the page, then click Create Distribution

The Status column shows  In Progress for your distribution. After Amazon CloudFront has created your distribution, the value of the Status column for your distribution will change to Deployed. At this point, it will be ready to process requests. This should take around 15-20 minutes. The domain name that Amazon CloudFront assigns to your distribution appears in the list of distributions. It will look similar to dm2afjy05tegj.cloudfront.net

Amazon CloudFront now knows where your Amazon S3 origin server is, and you know the domain name associated with the distribution. You can create a link to your Amazon S3 bucket content with that domain name, and have Amazon CloudFront serve it.

Task 3: Create a Link to Your Object

  1. Copy the following HTML into a new text file:
<html>
<head>My CloudFront Test</head>
<body>
<p>My text content goes here.</p>
<p><img src="http://DOMAIN/OBJECT" alt="my test image" /></p>
</body>
</html>

  1. In your text file:
  • Replace DOMAIN with your Amazon CloudFront Domain Name for your distribution. You should see this on the CloudFront Distributions page.
  • Replace OBJECT with the name of the file that you uploaded to your Amazon S3 bucket
  1. Save the text file to your computer as 

  2. Open the web page you just created in a browser to ensure that you can see your content.

The browser returns your page with the embedded image file, served from the edge location that Amazon CloudFront determined was appropriate to serve the object.

Task 4: Delete Your Amazon CloudFront Distribution

You can clean up your resources by deleting the Amazon CloudFront distribution and the Amazon S3 bucket.

  1. In the AWS Management Console, select the check box  for your CloudFront distribution.

  2. At the top of the screen, click Disable

  3. Click Yes, Disable

  4. Click Close

The value of the State column immediately changes to Disabled.

  1. Wait until the value of the Status column changes to Deployed.

  2. Select the check box  for your CloudFront distribution, then configure:

  3. Click Delete then:

  • Click Yes, Delete
  • Click Close

Task 5: Delete Your Amazon S3 Bucket

  1. On the Services menu, click S3.

  2. Click S3 bucket you created.

  3. Select  the file.

  4. In the Actions  menu, select Delete

  5. In the Delete objects window, click Delete

  6. Click Amazon S3 link at the top of the window and then select the bucket name that starts with cfbucket

  7. Click Delete then:

  • Enter the name of your bucket
  • Click Delete bucket

You have now released the resources used by your CloudFront distribution and Amazon S3 bucket.

End Lab

Follow these steps to close the console, end your lab, and evaluate the experience.

  1. Return to the AWS Management Console.

  2. On the navigation bar, click awsstudent@<AccountNumber>, and then click Sign Out.

  3. Click End Lab

  4. Click OK

  5. (Optional):

  • Select the applicable number of stars 
  • Type a comment
  • Click Submit

    • 1 star = Very dissatisfied
    • 2 stars = Dissatisfied
    • 3 stars = Neutral
    • 4 stars = Satisfied
    • 5 stars = Very satisfied

You may close the dialog if you don't want to provide feedback.

Conclusion

 Congratulations! You now have successfully:

  • Created a new Amazon CloudFront distribution
  • Used your Amazon CloudFront distribution to serve an image file
  • Deleted your Amazon CloudFront distribution when it is no longer required

Additional resources

For feedback, suggestions, or corrections, please email us at [email protected].

 

 

Share: