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

enable the public access to bucket.

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

select the delivery method

select s3 bucket name in origin domain name

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 .

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

Step #3: Testing CloudFront Distributions

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

paste the domain name on browser

click on Disable to disable CloudFront Distributions.

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 Rahul Deshpande

I am Rahul Deshpande AWS Certified Solution Architect, Likes to explore new technology stacks and believe in sharing knowledge.

Leave a Comment

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

Share via
Copy link