An AWS S3 Bucket as a Website

Cloud Playground

If you are not on the Cloud train, buy a ticket and come aboard. Here’s a way to get up and running with Cloud Services quickly. Have you ever wanted to have access to unlimited internet storage? You have to do a little work but you can build your own internet storage system. AWS will give you 5GB free but you can increase the storage as much as you like. I do 50TB for $12 a month. This affords the flexibility Dropbox, Google Drive, and the others cant offer. I’m assuming you know the difference between Cloud Storage and other storage (CIFS, NAS, SCSI and such). Cloud Storage is remote and accessed by your browser (REST API). The files are actually sitting on storage owned by Amazon. Let’s build. First, you need to sign up for a free Amazon Web Services Account (AWS). They give you a certain amount of Cloud Service capability free for a year. Let’s concentrate on Simple Storage Services (S3). Log on to the AWS Management Console and follow along.


STEP1: Go to the S3 services section of the AWS Console.

STEP2: Create an S3 bucket. The name cannot exist anywhere in AWS so don’t try to use “mybucket” as the name. Use something like “mybucketbuzzlightyear001”. You can take all the defaults and click create in the lower left or review all defaults and click through each step.

STEP3: Upload some files into your new S3 Bucket. Whatever you want. You have officially created a Cloud Resource and placed data in the Cloud.

STEP4: Now we need to give the internet read-only access to your bucket. AWS by default tries it’s best NOT to let you open up access to the world and for good reason. How many headlines have you seen where someone left open millions of records to the internet because they did not pay attention to the security settings. We will be working on our test bucket with non-critical data. Click the permissions tab and uncheck the “Block all public access…” It will complain but we are only working on our test bucket. Type in “confirm” and click confirm. This is like a light switch. This function cuts off all access even if you try to open it with ACL’s and Bucket Policies.

STEP5: Go to the Permissions tab and choose “Bucket Policy”. We need to allow anyone to get a file from our bucket. Copy and paste this into the JSON policy creator. It basically allows anyone to read any file in your bucket. DISCLAIMER: DO NOT DO THIS IN A OPERATIONAL ENVIRONMENT. THERE ARE MANY WAYS TO SECURE YOUR BUCKET.

{
“Version”: “2019-4-29-Chet”,
“Statement”: [
{
“Sid”: “AddPerm”,
“Effect”: “Allow”,
“Principal”: “”, “Action”: “s3:GetObject”, “Resource”: “arn:aws:s3:::mybucketbuzzlightyear001/”
}
]
}

Remember to change the “arn” at the bottom to the name of your bucket. Save the policy.

Now we turn it into a Website. Goto the Properties Tab and chose Static Website Hosting. You must have an index.html file in the bucket. Create a file an insert this HTML text. Upload the file to your bucket. Be sure to name it index.html.

<html>

<head>

    <title>Bunch of files</title>

</head>

<body>

    <b>Hey out there!</b>

    This is my test S3 bucket!

</body>

</html>

Type index.html in the box. Don’t worry about the other choices. You can look them up later. Click Save.

 

Now, reopen the Static website hosting box. At the top, you will see the URL (hyperlink) for your S3 Bucket. Copy this URL and paste into a browser.

http://mybucketbuzzlightyear001.s3-website-us-east-1.amazonaws.com

This is what you should see!!!

If you want to see a file, tack it on to the end of the URL.

That’s it. Hope you enjoyed this article. Leave a comment if you like.

Advertisements

2 thoughts on “An AWS S3 Bucket as a Website”

Leave a Reply to MxAdm!n Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s