Deploy Your Static Website on AWS S3

Опубликовано: 31 Март 2025
на канале: buckmasterinstitute
56
3

Created and recorded by Aman Chhina. July 2021

Overview
1. Introduction
2. Navigate to S3 Console
3. Create unique Bucket and give Public Access
4. Upload static content and generate Bucket Policy to get that content
5. Enable static hosting and indicate homepage
6. Follow url to publicly available static website
7. Review and Outro

Let's begin by being logged into the AWS console, and once you are let us navigate to the S3 console. Inside of here we will create a new bucket. The bucket name needs to be unique, and let us keep the default region, however let us remove the public access block on it. This is because for us to retrieve items inside of this bucket, it must be publicly accessible, and as such we acknowledge that the items inside of this bucket are public. Enable versioning incase of us updating one of our html files and we'd like to revert back, this is incredibly helpful for that. Finally let us create our bucket.

The bucket is now created, however we have no items inside of our bucket. So let us upload our static content inside the bucket. Once that is done, we now need a bucket policy that allows us to retrieve the static content we have uploaded. So let us edit the permissions and add a bucket policy. We will use the bucket policy generator for ease of use. We are creating an S3 bucket policy so let's select that appropriately, our effect is Allow as we are granting access, and the principle is *, which indicates that it is providing these permissions to everything inside of the ARN. Next up the action we want to attach to this policy is the getObject action, so let us select that, and then let us provide the ARN (Amazon Resource Name) for which this policy is being generated for. To get the ARN let us go back to where we clicked edit the bucket policy, and we will now see the ARN readily available, so let us copy and paste that. Finally add the policy and generate it. Take the now created JSON policy, copy this and paste it inside of the permissions bucket policy. Once that is done and saved we now have access to retrieve the static content inside of our bucket.

Now we want to enable static web hosting, so let us go to properties, go to to the bottom and enable this. Provide the homepage in this case that will the index.html page, and we have no error page and no redirect rules, so let us proceed to saving this. Once this is saved if we again navigate to the bottom of the page we will now see the URL for which we can access our static web content. There we go, we have deployed our static website on AWS S3.

So today we created a new bucket and gave it public access, uploaded a static website and generated a bucket policy that allows us to get that content. Enabled static hosting so we can have a URL for our now deployed website. This was a very simple website we uploaded today, however the idea remains the same for any static content. So hopefully you guys found this helpful and educational, if you did please consider liking and subscribing and see you guys next time.