The first step is still to create a website first, the content will come later 😂. To host a static website, AWS provides Static website hosting feature based on Amazon S3.
Some key things to know about S3:
Access the AWS S3 service on the console or through the link AWS S3
Choose Create Bucket.
On the Create bucket
ap-southeast-1
workshop1-123
💭 Mẹo
Since the bucket name must be unique, I usually add a sequence of numbers after the desired name.
ACLs enabled
I acknowledge that the current settings might result in this bucket and the objects within becoming public.
in the warning Turning off block all public access might result in this bucket and the objects within becoming publicCreate Bucket
-> Bucket workshop1-123
create success.
Feature S3 static hosting in the Properties tab. Choose Properties and then navigate to Static website hosting at the bottom of the tab.
Choose Edit in Static website hosting
On the Edit static website hosting:
Static website hosting: enable
Index document: index.html
Click Save changes
At the Static website hosting feature, save the bucket website endpoint url for later use
ℹ️ Note
At this point, this S3 website endpoint may still not be working because:
- The website does not have the index.html file to display.
- Even if there is a file, users still do not have permission to access files within S3. -> The next step will configure a policy to grant users access to the content of files inside S3.
Choose Permissions tab
Navigate to the Bucket policy section, choose Edit
Paste the following json policy snippet:.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Statement1",
"Principal": "*",
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::workshop1-123/*"
]
}
]
}
👉 Brief
This JSON policy configures permissions to allow all users (Principal) to perform the action (Action)s3:GetObject
on objects within the bucket namedworkshop1-123
. This means that everyone, including unidentified users, has the permission to access and read (GetObject) objects within this bucket.
Choose Save changes
-> The creation and configuration of a website using the Static website hosting feature of S3 is now complete.