After creating the HTML and CSS files, I created the static
website, hosted on AWS S3. Static sites do not need to be served by a web server. You don't need the infrastructure that is otherwise required to host a web framework. Let's take a look.
Prerequisites
AWS profile set up
index.html
error.html
styles.css
I have named the files index.html
, styles.css
as per naming conventions. You don't need the CSS file to make it work, however it has all the styling information. Error.html
is returned when an error occurs. Here is a sample HTML
file content.
<!DOCTYPE html>
<html>
<body>
Hello World!
</body>
</html>
Create a bucket
I created a bucket from the S3 console on AWS and called it blog.komlalebu.com
, ignoring all the settings.
Once inside the bucket, I clicked on the properties
tab for the bucket.
Then I clicked on edit, in the static website hosting card.
Then I enabled
static website hosting, and set Host a static website as the Hosting type
. I also mentioned the names of my Index
document and Error
document, within the bucket.
Once it was turned on I got back the endpoint from the S3 bucket. This the static website URL: http://blog.komlalebu.com.s3-website-us-east-1.amazonaws.com
Upload the documents
Once the bucked was created I uploaded the files (index.html, error.html, styles.css) to the bucket
Edit the bucket permissions
I modified the bucket permissions to allow everyone to getObject's from the bucket. As basic policy could look like the below. Just make sure to update the "Resource" to be the name of your S3 bucket. This may not be the most secure
way to do it.
{
"Version": "2012-10-17",
"Id": "Policy1604391079488",
"Statement": [
{
"Sid": "Stmt1604391073964",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource":
"arn:aws:s3:::blog.komlalebu.com/*"
}
]
}
And it was done. However there are other ways of doing it using AWS CLI.
Top comments (0)