Hosting a Website on Amazon S3

For this project we will learn how to host a website on Amazon S3. S3 is essentially storage on the cloud. S3 stands for “Simple Storage Service”. Imagine a hard drive you have in your computer or even a USB. Obviously thats storage but now imagine you don’t have it. Its in the cloud. That is Amazon S3, except we are learning how to utilize these tools ourselves so its no longer a “mystery”.

Log into AWS

navigate to S3 in the search bar. Ensure youre on the region closest to you. For our project we are going to use Virginia US east 1. If youre following along pick whats best for you.

go to create bucket on the right hand side.

Lets keep bucket type general, we will keep bucket namespace as global because I dont see a reason to change it.

for the bucket name lets name it something not completely retarded. But still making some kind of sense. Website_hosting_s3_whatsahacker

Interesting to know about bucket names An S3 bucket name is globally unique. After you create a bucket, no other AWS account in the entire world can use your bucket's name (unless you delete the bucket).

For our project we will be enabling ACLs. We are doing this for two reasons I want to get a better understanding of using ACLs in my environments that I own and ACLs give better granular control over your objects. Bucket policies are easier for sure but doesn’t it make sense to make life harder in a learning environment so its not harder in production?

click “bucket owner preferred”

If new objects written to this bucket specify the bucket-owner-full-control canned ACL, they are owned by the bucket owner. Otherwise, they are owned by the object writer.

We want people to be able to see our website so lets uncheck “block all public access” Block Public Access settings for this bucket

Were going to need to check the warning box that we understand our bucket may be public. They think we are retarded.

I am big in not having a single point of failure and rollbacks. So we are going to enable bucket versioning.

For reference this is what it does Versioning is a means of keeping multiple variants of an object in the same bucket. You can use versioning to preserve, retrieve, and restore every version of every object stored in your Amazon S3 bucket. With versioning, you can easily recover from both unintended user actions and application failures. Learn more 

For encryption we will leave it standard as it saves us money. Definitely something I should come back to to and learn but I just want to master the basics.

Hit “Create bucket”

It failed. I had to change Website_hosting_s3_whatsahacker to Website-hosting-s3-whatsahacker.

Boom. Now it works. Youve just created your first s3 bucket

I already have files for my website but now we can upload them to our s3 bucket. Once that is done you can close and begin hosting your site.

You can go to the “properties” tab on your site and scroll down to static website hosting. Its on the bottom so keep on scrolling. Edit that box.

Enable, host a static website and save.

click on the link generated.

i got an error though. I got the error because the page exists but the objects (files) we uploaded are private. So what is causing the error is the ACL preventing randoms from seeing the page generated. We need to make the objects public so others can view the webpage.

Go back to the objects click on both radio buttons and make public using acl. Now you should be able to see your page. Once you go back to your page you will see your website being hosted. Viola, we’ve done it.

Remember, after you create a project. Delete that shit unless you want to get charged for it/want to keep it alive.

As always stay curious, my friends.

Previous
Previous

Where the Hell Do I Even Start?

Next
Next

Cloud Security with AWS IAM