Complete the code to create an S3 bucket for static website hosting.
aws s3api create-bucket --bucket [1] --region us-east-1
The bucket name must be globally unique. Adding numbers helps ensure uniqueness.
Complete the code to enable static website hosting on the S3 bucket.
aws s3 website s3://[1]/ --index-document index.htmlYou must specify the exact bucket name where you want to enable website hosting.
Fix the error in the bucket policy to allow public read access for website files.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": [1],
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-static-site-bucket-123/*"
}
]
}To allow public read access, the Principal must be set to "*" which means everyone.
Fill both blanks to configure the bucket policy to allow public read access only to website files.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": [1],
"Action": [2],
"Resource": "arn:aws:s3:::my-static-site-bucket-123/*"
}
]
}The Principal must be "*" for public access, and the Action must be "s3:GetObject" to allow reading objects.
Fill all three blanks to sync local website files to the S3 bucket and make them publicly readable.
aws s3 sync [1] s3://[2] --acl [3]
Use the local folder path, the bucket name, and set ACL to 'public-read' to allow public access to files.