Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.51 KB

host_static_website_using_s3.md

File metadata and controls

58 lines (38 loc) · 1.51 KB

Host static website using S3

  1. Create two S3 bucket with your domain name (www and non-www)

    1. example.com
    2. www.example.com
  2. Configure non-www bucket to redirect to www bucket

Redirect non-www to www

  1. Upload your web content to www bucket

  2. Configure www bucket for web-hosting by selecting static website hosting

Enable Static Website Hosting

  1. Make www bucket as public and add the below policy
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect":"Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::www.example.com/*"
        }
    ]
}

Make Bucket public

Bucket Public Policy

  1. Create AWS route53 public hosted zone with the same name as the domain name (Non-WWW).

  2. Update GoDaddy NS with AWS provided NS (without ending dot(.).

Adding Name server in AWS

  1. In AWS Route53

    create A Type recordset for the non-www domain and select

    1. Enable Alias
    2. Alias to S3 website endpoint,
    3. Select the region of your bucket
    4. Select your S3 main bucket (i.e non-www domain)

    create A Type recordset for www subdomain and repeat the above steps/points except the selecting S3 www bucket.

Create A Record

  1. Access your web site from browser. Enjoy