Setting Up An S3 Static Website Using AWS CLI: Description
Setting Up An S3 Static Website Using AWS CLI: Description
Setting Up An S3 Static Website Using AWS CLI: Description
md 2/23/2022
Description
In this article, I'll be setting up an S3 bucket website. I'll also verify the website is accessible and working as
expected. S3 bucket websites are excellent for hosting single-page, customer-facing content, as they are easy
to set up and offer the same high availability and scalability as S3.
1. Open a terminal session and log in to the provided EC2 instance via SSH using the credentials provided
on the lab page:
Create an S3 bucket in the us-east-1 region, replacing <UNIQUE_BUCKET_NAME> with a unique bucket
name, and using the S3 API:
1/3
AWS CLI S3 Static Web site.md 2/23/2022
Issue the AWS S3 API CLI command to enable the "Static website hosting" property of your bucket. In
this same command, you'll also provide the index.html page, which is what your bucket URL will serve:
4. Modify Provided S3 Policy File and Use It to Modify the Bucket Policy
vim policy_s3.json
{
"Version":"2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<UNIQUE_BUCKET_NAME>/*"
}
]
}
5. Use the S3 policy file to modify the bucket policy so your objects are publicly accessible, which is a
requirement for S3 static websites:
6. Clone our web site from github Page and Upload File to S3 Website Bucket
2/3
AWS CLI S3 Static Web site.md 2/23/2022
Enter the S3 website URL for your bucket in the browser to ensure it's working.
You can also test from the terminal using the curl command:
curl http://.s3-website.us-east-1.amazonaws.com
8. To delete all the objects from an S3 bucket, --recursive option can be used after the specified bucket
name as shown below.
aws s3 rb s3://bucket-name
10. Instead of 8th and 9th step you can force to delete, so you can imply that command shown below
Thank You!
3/3