-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Problem
I am referring to this page: https://github.com/fourTheorem/serverless-ecommerce-workshop/tree/main/lessons/01-deploying-the-frontend
When I tried to run this command under the "Bucket policies" section:
aws s3api put-bucket-policy --bucket $FRONTEND_BUCKET --policy file://policy.jsonI encountered the following error:
An error occurred (AccessDenied) when calling the PutBucketPolicy operation: Access Denied
Analysis
The error indicates that the operation was denied due to access control restrictions on the S3 bucket. This typically happens when the bucket has public access policies that block changes to bucket policies.
Fix
To resolve this issue, I had to disable the BlockPublicPolicy setting on the S3 bucket. The following command was used to update the bucket's public access block configuration:
aws s3api put-public-access-block --bucket $FRONTEND_BUCKET --public-access-block-configuration "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false"
After running the above command, I was able to successfully execute the original put-bucket-policy command without encountering the Access Denied error.
Additional Note
The command also ensures that "Block all public access" is turned off for all four settings, which is required before the pages are served.