Building and managing your storage repository is expensive and time-consuming; first, you must get racks of dedicated hardware, and adding more capacity costs a lot of time and money to deploy and host your resources. AWS S3 stands for Simple Storage Service. It’s scalable, highly available, and supports multiple integrations with different AWS resources, and you can store files, folders, and source code on AWS S3. Amazon S3 provides developers and cloud engineers with safe and secure object storage to store files and host resources like a static website which can also be done directly on the Web UI.

With the AWS S3 static hosting feature, you just have to choose the region where you want your data stored, and you can begin hosting and storing your files, source code, repositories, and folders in S3.

In this tutorial, you’ll learn how to host a Static Website on AWS S3 Bucket.

Prerequisites


Getting Started

Create an S3 Bucket

You must create an S3 bucket from the AWS console or CLI to get started.

  • In your AWS Console, search for S3, and click Create bucket.

  • Enter the bucket name and the region you want to host your bucket.

  • You can control access to objects that will control the buckets using access control list. We’re not integrating different AWS objects on our buckets, so disabling the setting is best.

  • Public access is given to buckets and objects through access control lists (ACLs), bucket policies, access point policies, or all. To ensure that public access to this bucket and its objects is blocked, turn on Block all public access. These settings apply only to this bucket and its access points.

  • Next, once you’re done with the settings, create the bucket. Once you’ve created the bucket, you’ll see your S3 Bucket in the bucket list.
  • You’ll be able to see all the features, permissions, and properties associated with your bucket in your bucket.

  • Next, upload your static website with all the files inside the S3 bucket. You can either add the files or drag and drop your folders into your Bucket.  Once you’re done, you’ll see the folders you uploaded in your Bucket.

  • Configure and set other permissions. You can use the Standard storage class in the storage class since you’ll be accessing it more frequently.

  • Next, click on Upload. Your folders and files are uploaded automatically to AWS S3.

  • Next, click on index.html; you’ll see the details of your S3 bucket with the object overview. The object URL will act as your endpoint accessible from the internet.

  • When you click on the object URI, you might see something like this because you haven’t given the Static Website Hosting permissions to your S3 bucket.

  • To enable static website hosting, back in your S3 bucket properties, click on Static Website Hosting, and it will allow it; specify the hosting type and the default name of your website, and save your changes.

  • Unblock all public access in your S3 Bucket permission settings and click on save.

  • Also, select all your objects and make them public using ACL from the actions drop-down menu.

  • Back in your object properties, copy the Object URL.

  • Next, paste your Object URL into your browser. You can see your static website hosted and made accessible to the public.

You can view your website and use it anywhere. With this, you can host your websites for free using AWS S3.


Conclusion

Amazon S3 lets you preserve, retrieve, and restore every version of every object in an Amazon S3 bucket. So you can easily recover your files and folders if they were accidentally deleted by your team member, and you only pay for the storage you actually use. If you want to define your range of storage classes for your application use-case with lifecycle policies, feel free to book a call with our Solution Engineers here.