EMAIL SUPPORT

dclessons@dclessons.com

LOCATION

US

LAB Configuring Cloud Front

LAB Configuring Cloud Front

LAB Configuring Cloud Front

Task :

In this lab , we will create the Amazon CloudFront distribution , which will distribute image file stored in an Amazon S3 bucket.

Step1: Create S3 Bucket

Go to AWS Service | Select S3 Service under Storage Section

Go to Bucket Section | Click on Create Bucket

Under Create Bucket | Bucket name: dc12345 , AWS region: Select US-East (Virginia) us-east-1.| Object Ownership : Select ACLs Enabled and Select Object Writer

Under Block Public Access Setting For this bucket : Disable and Select Acknowledge Section

Keep all setting default | Click on create Bucket

Now Upload any image in to that bucket.

Step2: Create Custom Error pages

In this section , we will create custom error pages for cloud front to return when origin returns HTTP 4xx or 5xx errors.

Select your Bucket | Click on Create Folder

Under Folder Section | Folder name: CustomErrors | Server Side Encryption : Disable

Now Under this folder upload block.html and error.html

For block.html : open text file and put this code, and save it as block.html

<html>

This Dclessons content is blocked in your location!!!

For error.html : Open Text file , put this code and save it as error.html

<html>

This is Dclessons Error Page

Step3: Make Object public

On Click on Image name , you uploaded and take it's URL and open it on browser , here you have see that access Is denied and object is not publicly accessible.

Go to your bucket | Permission | Now Scroll down to Bucket Policy | Click on Edit | and use below code in it. Just change the name of bucket ARN with your own bucket ARN in both resource option in the code.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:ListBucket"
      ],
      "Principal": {
        "AWS": "*"
      },
      "Resource": ""
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:PutObject"
      ],
      "Principal": {
        "AWS": "*"
      },
      "Resource": ""<Your own bucker ARN>/*"
    }
  ]
}

Now access the image URL again and you see you Image now publicly accessible.

Step4: Create CloudFront Distribution

Go to AWS Services | Under networking & Content Delivery | Select Cloud Front


Comment

    You are will be the first.

LEAVE A COMMENT

Please login here to comment.