How to Host Static Websites on AWS S3?

Posted on Oct 11, 2023

How to Host Static Websites on AWS S3?

How to Host Static Websites on AWS S3?

Hosting a Static Website on AWS S3 has a lot of benefits. Additionally, you must complete some steps correctly while hosting your website on S3.

Today in this article, we will explore the benefits of hosting a static website on AWS S3, how it works, and the step-by-step hosting guide. So please stick with us to know everything about AWS S3.

What is Amazon S3?

Before diving deep into it, clear all the basics first.

Amazon Simple Storage Service, or Amazon S3, is an object storage service offering industry-leading scalability, security, performance, and data availability.

Mainly Amazon S3 is used on static websites, separate web pages including static content. Moreover, many people prefer Amazon S3 for backup.

Benefits of Hosting a Static Website on AWS S3?

Storage Classes

According to your use cases, Amazon S3 offers a specified range of storage classes, which helps you archive data at the lowest costs.

In the Amazon S3 bucket, you can choose a service per your data and cost, like, S3 Glacier Flexible retrieval, S3 Glacier Instant Retrieval, S3 Glacier Deep Archive, and more.

For more information read the book: Mastering AWS S3 Storage: Learn To Manage and Secure AWS S3 Storage.

Storage Management Service

In storage management service, you can manage costs, reduce latency, manage regulatory requirements, etc.

Explore more about: Microsoft Azure Vs AWS Vs Google Cloud

Additionally, you can easily save multiple copies of your data for compliance requirements.

Data Processing

To automate the workflow and trigger the data transfer, you can use AWS S3 object Lambda and Event notifications features.

To trigger workflows, Amazon Simple Notification Service (Amazon SNS), AWS Lambda, and Amazon Simple Queue Service (Amazon SQS) are made for Amazon S3.

Access Management

Auditing and managing access to your buckets and objects is one of the great features of AWS S3. You have access only to the S3 bucket that you create.

By default, the S3 bucket and the object in them are private.

Read More about: Cost-effective Use cases & Benefits of Amazon S3

How to Host a Static Website on AWS S3? Step-by-Step Guide

  1. Sign up and create a bucket in Amazon S3
  2. Enable the public to read permission for the bucket
  3. Configure Static website hosting for your bucket.
  4. Upload static website code
  5. Validate the code if there are any errors.
  6. If you are still confused, Adex is here to help you.

Sign up and Create a Bucket in Amazon S3

You must need an AWS account. To create an AWS account, first Click here. Once you have completed the sign-up process, you must configure your S3 storage service to host your static website.

Read more about: What is serverless computing AWS?

After that, to create the bucket, click on Create Bucket and give a name to your bucket. Be careful: If your website name is www.websitename.com, your bucket name must be www.websitename.com.

For those unaware of the Amazon S3 bucket, the bucket is a container for the objects stored on AWS S3.

Enable the Public Read Permission for the Bucket

AWS doesn’t allow public read permission on the S3 bucket by default, so you must do it manually.

On the permission tab, you see the default behavior is blocked public access, which you need to change to public access. Below is the process of how to give the public read permission.

You can also manage permission by adding the below code to your bucket policy page.

{
“Version”: “2012-10-17”,
“Statement”: [
{
“Sid”: “PublicReadGetObject”,
“Effect”: “Allow”,
“Principal”: ““, “Action”: [ “s3:GetObject” ], “Resource”: [ “arn:aws:s3:::Bucket-Name/“
]
}

Remove the tick icon ahead of Block all public access. It also warns you while removing the tick, and you need to acknowledge that you operated by yourself intentionally.

Read Also: How to Install and Upgrade the AWS CDK CLI ?

You need to add a bucket policy to grant public read access to anyone on the internet. Here’s a short guide on how to create a bucket policy:

  1. Choose the bucket that you want to change or add a privacy policy.
  2. Click on permission
  3. Under bucket policy, click edit.
  4. After that, click on the policy generator to generate the bucket policy, or you may manually create the bucket policy.
  5. Select the type of policy for your S3 bucket on the AWS policy generator page.
  6. Add all the information in the provided field and hit on add statement button.
  7. After that, click on generate policy and copy the approach.
  8. Return to the edit bucket policy and paste the code you copied in the previous step.
  9. After completing all the steps correctly, hit the save changes button, which redirects you to the bucket permission section.
  10.  

Configure Static Website Documents for Your Bucket

As your website can be public, you must configure static website hosting for the bucket you created in the previous steps.

To configure your static website for your bucket, you need to create or name the document index.html. The step-by-step guide uploads your document on the S3 bucket with the index.html name below.

Upload Static Website Code

First, create an index.html file. Note that it’s case sensitive, so don’t create using an upper case like Index.Html must use ‘index.html.’

And then save the file index locally.

Now it’s time to enable static website hosting for the bucket. There are two ways to do this:

  1. Into the console bucket listing, drag and drop the file you created in the previous step.
  2. Click on the upload button and follow all the steps correctly.

Validate your Code if there are any errors

If you followed all the above steps correctly, there might be no errors. However, validating once is a better idea before going live. Here’s how you validate your website code.

  1. Choose the name of your bucket.
  2. Choose properties.
  3. Under the Static website hosting, choose your Bucket Website Endpoint.
  4. If your index website opens in a new tab, it’s okay. There’s no problem. If not, you may follow all the above steps once again.

How to Host Static Websites on AWS S3?
Ravi Gupta

Latest Blogs

New AWS Announcement for October 2023

New AWS Announcement for October 2023


New AWS Announcement for October 2023

Adex International

Nov 08, 2023

Sustainability in the AWS Well-Architected Framework: A Comprehensive Guide

Sustainability in the AWS Well-Architected Framework: A Comprehensive Guide


Sustainability in the AWS Well-Architected Framework: A Comprehensive Guide

Adex International

Oct 19, 2023

AWS New Announcement Sept 2023

AWS New Announcement Sept 2023


AWS New Announcement Sept 2023

Adex International

Oct 17, 2023

Migrate Gitlab PostgreSQL Database to Custom Location Using Ansible

Migrate Gitlab PostgreSQL Database to Custom Location Using Ansible


Migrate Gitlab PostgreSQL Database to Custom Location Using Ansible

Saugat Tiwari

Oct 11, 2023

Mastering DevOps: Your Ultimate Guide to DevOps Managed Services

Mastering DevOps: Your Ultimate Guide to DevOps Managed Services


Mastering DevOps: Your Ultimate Guide to DevOps Managed Services

Biswash Giri

Oct 11, 2023

Discover the Benefits of Security as a Service (SECaaS) for your Business

Discover the Benefits of Security as a Service (SECaaS) for your Business


Discover the Benefits of Security as a Service (SECaaS) for your Business

Saugat Tiwari

Oct 11, 2023

Port Forwarding Using AWS System Manager Session Manager

Port Forwarding Using AWS System Manager Session Manager


Port Forwarding Using AWS System Manager Session Manager

Saugat Tiwari

Oct 11, 2023

Maximizing Directory Services with LDAP: Creating OUs, Groups, and Users for Improved Authentication and Access Control

Maximizing Directory Services with LDAP: Creating OUs, Groups, and Users for Improved Authentication and Access Control


Maximizing Directory Services with LDAP: Creating OUs, Groups, and Users for Improved Authentication and Access Control

Biswash Giri

Oct 11, 2023

AWS Migration Tools: A Comprehensive Guide

AWS Migration Tools: A Comprehensive Guide

IntroductionAWS migration tools are a comprehensive set of services and utilities provided by Amazon...


AWS Migration Tools: A Comprehensive Guide

Binaya Puri

Oct 11, 2023

Difference Between AWS Cloudwatch and Cloudtrail

Difference Between AWS Cloudwatch and Cloudtrail

AWS CloudWatch and AWS CloudTrails are sometimes difficult to distinguish. This article seeks to d...


Difference Between AWS Cloudwatch and Cloudtrail

Sabin Joshi

Oct 11, 2023

New AWS Announcements for June 2023 - Adex

New AWS Announcements for June 2023 - Adex


New AWS Announcements for June 2023 - Adex

Ravi Gupta

Oct 11, 2023

Top 7 Applications Of Cloud Computing In Various Field

Top 7 Applications Of Cloud Computing In Various Field


Top 7 Applications Of Cloud Computing In Various Field

Susmita Karki Chhetri

Oct 11, 2023

Ingesting and Monitoring Custom Metrics in CloudWatch With AWS Lambda

Ingesting and Monitoring Custom Metrics in CloudWatch With AWS Lambda


Ingesting and Monitoring Custom Metrics in CloudWatch With AWS Lambda

Tej pandey

Oct 11, 2023

7 Types of Security in Cloud Computing?

7 Types of Security in Cloud Computing?


7 Types of Security in Cloud Computing?

Mukesh Awasthi

Oct 11, 2023

Cost-effective Use cases & Benefits of Amazon S3

Cost-effective Use cases & Benefits of Amazon S3


Cost-effective Use cases & Benefits of Amazon S3

Nischal Gautam

Oct 11, 2023

IT Outsourcing: Everything You Need To Know

IT Outsourcing: Everything You Need To Know

The world has changed, and as technology advances, so does the world of work. Gone are the day...


IT Outsourcing: Everything You Need To Know

Roshan Raman Giri

Oct 11, 2023

Getting Started with Amazon Redshift in 6 Simple Steps

Getting Started with Amazon Redshift in 6 Simple Steps


Getting Started with Amazon Redshift in 6 Simple Steps

Tej pandey

Oct 11, 2023

How to Host Static Websites on AWS S3?

How to Host Static Websites on AWS S3?

How to Host Static Websites on AWS S3? Hosting a Static Website on AWS S3 has a lot of benefits....


How to Host Static Websites on AWS S3?

Ravi Gupta

Oct 11, 2023

The Importance of Managed Cloud Security for Businesses

The Importance of Managed Cloud Security for Businesses


The Importance of Managed Cloud Security for Businesses

Roshan Raman Giri

Oct 11, 2023

How To Use Amazon S3 For Personal Backup?

How To Use Amazon S3 For Personal Backup?


How To Use Amazon S3 For Personal Backup?

Tej pandey

Oct 11, 2023

Major AWS Updates &Announcements of 2023 - March

Major AWS Updates &Announcements of 2023 - March


Major AWS Updates &Announcements of 2023 - March

Roshan Raman Giri

Oct 11, 2023

How To Insert Data Into a DynamoDB Table with Boto3

How To Insert Data Into a DynamoDB Table with Boto3

DynamoDB is used for many use cases, including web and mobile applications, gaming, ad tech,...


How To Insert Data Into a DynamoDB Table with Boto3

Binaya Puri

Oct 11, 2023

How to Install and Upgrade the AWS CDK CLI

How to Install and Upgrade the AWS CDK CLI


How to Install and Upgrade the AWS CDK CLI

Nischal Gautam

Oct 11, 2023

Ultimate Guide on Creating Terraform Modules

Ultimate Guide on Creating Terraform Modules


Ultimate Guide on Creating Terraform Modules

Tej pandey

Oct 11, 2023

What is serverless computing?

What is serverless computing?


What is serverless computing?

Tej pandey

Oct 11, 2023

AWS Well-Architected Framework Security Pillar

AWS Well-Architected Framework Security Pillar

The Amazon Well-Architected Framework is a set of recommendations and practice guidelines for develo...


AWS Well-Architected Framework Security Pillar

Binaya Puri

Oct 11, 2023

Amazon FSx for Lustre, Windows, and NetApp ONTAP

Amazon FSx for Lustre, Windows, and NetApp ONTAP

Amazon FSx for Lustre, Windows, and NetApp ONTAPAmazon FSx is known for its fully managed, hig...


Amazon FSx for Lustre, Windows, and NetApp ONTAP

Ravi Gupta

Oct 11, 2023

How to Choose the Right Cloud Service Provider?

How to Choose the Right Cloud Service Provider?


How to Choose the Right Cloud Service Provider?

Tej pandey

Oct 11, 2023

25 New AWS Services Updates from AWS Re:Invent 2022

25 New AWS Services Updates from AWS Re:Invent 2022


25 New AWS Services Updates from AWS Re:Invent 2022

Susmita Karki Chhetri

Oct 11, 2023

AWS Managed Hosting Services And Dedicated Hosting Benefits

AWS Managed Hosting Services And Dedicated Hosting Benefits


AWS Managed Hosting Services And Dedicated Hosting Benefits

Tej pandey

Oct 11, 2023

What is Serverless Security? Risk & Best Practices

What is Serverless Security? Risk & Best Practices

Serverless computing  is a rising topic right now in the cloud tech industry. As per a Datad...


What is Serverless Security? Risk & Best Practices

Anup Giri

Oct 11, 2023

Difference Between Cloud Computing and Cybersecurity

Difference Between Cloud Computing and Cybersecurity


Difference Between Cloud Computing and Cybersecurity

Mukesh Awasthi

Oct 11, 2023

DevOps for Developers: How It Helps Streamline the Development Process

DevOps for Developers: How It Helps Streamline the Development Process

As per a survey done by Puppet, firms with DevOps practice have increased recovery speeds by 24 ti...


DevOps for Developers: How It Helps Streamline the Development Process

Roshan Raman Giri

Oct 11, 2023

New AWS Announcements for August 2023

New AWS Announcements for August 2023


New AWS Announcements for August 2023

Rohan Jha

Oct 11, 2023

The FinOps Chronicles

The FinOps Chronicles


The FinOps Chronicles

Anup Giri

Oct 11, 2023

AWS Auto scale Instance-Based on RabbitMQ Custom Metrics

AWS Auto scale Instance-Based on RabbitMQ Custom Metrics


AWS Auto scale Instance-Based on RabbitMQ Custom Metrics

Anup Giri

Oct 11, 2023

Overcome Merge Hell with Trunk based development and Continuous Integration

Overcome Merge Hell with Trunk based development and Continuous Integration


Overcome Merge Hell with Trunk based development and Continuous Integration

Rohan Jha

Oct 11, 2023

What's the difference between CapEX Vs OpEX in Cloud Computing?

What's the difference between CapEX Vs OpEX in Cloud Computing?


What's the difference between CapEX Vs OpEX in Cloud Computing?

Tej pandey

Oct 11, 2023

How Does Your Organization Keep Cloud Costs Under Control?

How Does Your Organization Keep Cloud Costs Under Control?


How Does Your Organization Keep Cloud Costs Under Control?

Susmita Karki Chhetri

Oct 11, 2023

Microsoft Azure vs AWS vs Google Cloud Comparison

Microsoft Azure vs AWS vs Google Cloud Comparison


Microsoft Azure vs AWS vs Google Cloud Comparison

Mukesh Awasthi

Oct 11, 2023

What are the Benefits of Amazon S3 Glacier?

What are the Benefits of Amazon S3 Glacier?


What are the Benefits of Amazon S3 Glacier?

Anup Giri

Oct 11, 2023

Leverage Azure Migrate to Discover and Assess Your AWS Instances for Smooth Migration to Azure

Leverage Azure Migrate to Discover and Assess Your AWS Instances for Smooth Migration to Azure


Leverage Azure Migrate to Discover and Assess Your AWS Instances for Smooth Migration to Azure

Rohan Jha

Oct 11, 2023