Aws part 14 → Static website hosting with S3 bucket

Aakib
2 min readMay 14, 2023

--

#75daysofaws

To host a static website on an Amazon S3 bucket in AWS, you can follow these steps:

  1. Create an S3 bucket: Log in to the AWS Management Console and go to the S3 service. Click on “Create bucket” and give it a unique name that follows the bucket naming rules. Choose the region where you want to create the bucket.
  2. Enable static website hosting: Select the newly created bucket, go to the “Properties” tab, and scroll down to find the “Static website hosting” section. Click on “Edit” and choose the option “Use this bucket to host a website.” Enter the index document name (e.g., “index.html”) and optionally provide an error document name.
  3. Upload your website files: Go to the “Bucket” section of the S3 console and click on your bucket’s name. Click on “Upload” to add your website files. You can either drag and drop the files or use the file upload interface.
  4. Set the permissions: Select all the uploaded files, click on “Actions,” and choose “Make public.” This makes the files accessible to visitors.
  5. Configure bucket policy: To ensure public access, go to the “Permissions” tab of your bucket and click on “Bucket Policy.” Add the following bucket policy, replacing “your-bucket-name” with the actual name of your bucket:
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::your-bucket-name/*"]
}]
}

6. Access your website: Once the files are uploaded, you can access your website by going to the following URL: http://your-bucket-name.s3-website-your-region.amazonaws.com. Replace "your-bucket-name" with your actual bucket name, and "your-region" with the AWS region where your bucket is located.

That’s it! Your static website is now hosted on the S3 bucket, and you can access it using the provided URL.

--

--

Aakib

Cloud computing and DevOps Engineer and to be as a fresher I am learning and gaining experiance by doing some hands on projects on DevOps and in AWS OR GCP