Once you land on the S3 page click on the Create bucket button to create a new storage bucket. This should present you with a form.
There are two main things to complete on this form among other optional settings:
Name of the bucket should be unique across the entire S3 network, so it only makes sense to use the domain name of your static site since it's unique across the web as well.
Scroll down to the Block Public Access... section of the form and uncheck the Block all public access button and check the I acknowledge that the current settings... right underneath that. This will allow your bucket to be publicly accessible for other apps to use for storage purposes.
You can now create your storage bucket by clicking on the Create bucket button.
Now that we have a storage bucket, the next step is to upload our website to the bucket.
For that, click on the newly created bucket, then click on the Upload button. This should open up your computer's file explorer. Be sure to select the web files and not the folder containing the files.
Next, we will need to specify the file to serve up when a visitor hits the domain name assigned to the site (index page) and a 404 page to use in case a user requests a non-existing page.
For that, go back to the bucket page and head to the Properties tab this time.
Scroll down to the Static website hosting section and click on edit.
You should now see a couple of fields:
Once you click on Save changes and scroll back to Static website hosting you will find a {url}.amazonaws.com
domain name, this should now point to your website.
This URL might not work yet and lead to a forbidden page.
The forbidden page error shows up because we have yet to set HTTP access permissions for our bucket.
To fix this, you need to go back into your bucket, then click on the Permissions tab close to the Properties tab.
From there, scroll down to the Bucket policy section, this a large text box with the policy settings in JSON.
You can go ahead and replace this with the JSON code below:
01: {
02: "Version": "2012-10-17",
03: "Statement": [
04: {
05: "Sid": "PublicRead",
06: "Effect": "Allow",
07: "Principal": "*",
08: "Action": [
09: "s3:GetObject",
10: "s3:GetObjectVersion"
11: ],
12: "Resource": "arn:aws:s3:::<your-bucket-name>/*"
13: }
14: ]
15: }
Now your website files will be publicly readable and thus can be viewed in the browser.
And that's it. Once you hit Save changes your website should now be accessible anywhere on the web!
Here is another article you might like 😊 Export CSV in Javascript