Tuesday, August 9, 2022

How To Host a Static Website On S3 Bucket With Custom Domain Name

S3 Bucket is a object level storage, You can store any number of objects in a bucket and can have up to 100 buckets in your account.

Amazon Route 53 is a highly available and scalable cloud domain name system (DNS) service. Enables to customize DNS routing policies to reduce latency.

 


We are using following services.

1) Route53
2) S3 Bucket

 

Step 1) Register a custom domain In Route 53.

 

Step 2) Create a bucket with your actual domain name and upload a simple index.html file or Source Code.

Note: Bucket Should be in "US East(N. Virginia) us-east-1" Region.

  • For Domain Bucket – freewaladomain.tk

 

Step 3) Edit the "Permission" Tab.


  • In Permission Edit the bucket Policy and paste following code.

Note: Replace the highlighted word with your domain name only.

{
  "Id": "Policy1659689783609",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1659689781458",
      "Action": [
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::freewaladomain.tk/*",
      "Principal": "*"
    }
  ]
}

 

Step 4) Edit the "Properties" Tab.


  • In Properties tab Come on "Static website hosting" and enable it.

 
  • Just Write the index.html under "Index document" Section then save.


  • Copy The bucket public URL and run in browser.

 

Step 5) Go To Route53 and map the A record with S3 Bucket URL

  • Type : A Record 

Enable Alias

  • Choose Endpoint : Alias To S3 Website Endpoint
  • Choose Region   : "US East(N. Virginia) us-east-1"
  • Choose S3 Endpoint : Select Fron the Right One


Step 6) Now, also Check with custom domain.

http://freewaladomain.tk

 


No comments:

Post a Comment

testing