How to Create CloudFront Distribution in AWS

In this article, we are going to cover Creating S3 bucket , creating bucket policy, How to Create CloudFront Distribution in AWS , testing cloudfront distribution and disable cloudfront distribution in AWS.

Step #1: Login to AWS Management console, create S3 bucket

create s3 bucket 1

enable the public access to bucket.

enable public access s3 bucket 2

Now, Upload static content in the bucket.

Enable the Static website hosting and give entry page and error page as index.html

Go to permission and create below s3 bucket policy and change your s3 bucket name

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicReadAccess",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::MYclaudfront/*" // Name of the bucket
        }
    ]
}

Change the below CORS policy also

[
    {
        "AllowedHeaders": [
            "*",
        ],
        "AllowedMethods": [
            "GET"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]

How to Create CloudFront Distribution in AWS

Step #2: Create the CloudFront Distributions

create cloudfron distribution in aws 3

select the delivery method

select delivery method 4

select s3 bucket name in origin domain name

add bucket in cloudfront

Add origin into the whitelist header and Enable compress objects automatically -> yes

Click on Create and wait till to create Cloudfront Distributions in AWS and it is going to take time approx. 30 min .

wait till complete 5

once completed verify the CloudFront Distributions Click on Cloud front ID for more details.

check cloudfron details 6

Step #3: Testing CloudFront Distributions

Open the browser, copy the domain name as shown below.

copy the domain name 7

paste the domain name on browser

open in browser 8

click on Disable to disable CloudFront Distributions.

disable cloudfron distribution 9

Conclusion:

We have covered Creating S3 bucket , creating bucket policy, How to Create CloudFront Distribution in AWS , testing cloudfront distribution and disable cloudfront distribution in AWS.

Related Articles:

How to Create IAM User in AWS Step by Step

How to Attach IAM Role to EC2 Instance using CLI

How to Create Ubuntu Instance in AWS [7 Steps]

How to Create Linux EC2 Instance in AWS

AWS Create EC2 Instance from Snapshot

How to connect to AWS EC2 Instance using MobaXTerm

How to Enable Password Authentication for AWS EC2

How to Connect EC2 Instance using Putty

How to Transfer files to AWS Instance using WinSCP [2 Steps]

How to Install AWS CLI on Amazon Linux

How to Mount EFS on EC2

Lambda Function to Start and Stop RDS Instance

Start and Stop EC2 Instance using Python Boto 3

How to Create AWS DocumentDB and Connect [3 steps]

How to Install MySQL 5.7 on Amazon Linux 2

How to Create Postgres Database in AWS and connect

Monitoring EC2 Instances using CloudWatch

Reference:

AWS CloudFront Distributions official page

About DevOps Hint

DevOps Hint Founded in 2020 Community Site where you can find about How to Guides, Articles and Troubleshooting Tips for DevOps, SRE, Sysadmins and Developers.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link