Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to create bucket in job 'Execute bucket.yml - Create Cloudformation Stack' #21

Open
LichP opened this issue Jun 7, 2023 · 0 comments

Comments

@LichP
Copy link

LichP commented Jun 7, 2023

The create_and_deploy_front_end job is failing in CircleCI:

Waiting for changeset to be created..
Waiting for stack create/update to complete

Failed to create/update the stack. Run the following command
to fetch the list of events leading up to the failure
aws cloudformation describe-stack-events --stack-name stack-create-bucket-4107f96

Exited with code exit status 255

When I run the describe-stack-events command, I see the following error:

CREATE_FAILED   Bucket cannot have ACLs set with ObjectOwnership's BucketOwnerEnforced setting (Service: Amazon S3; Status Code: 400; Error Code: InvalidBucketAclWithObjectOwnership; Request ID: PH3A3FN20TS9H7CA; S3 Extended Request ID: 3tsO51e7/ugunMvoeh/acWVGKAb+5hbumfFd+CPqfHSsYlT/bDHbSGOnePEySYVGWm1/hexc88o=; Proxy: null) 

This appears to be due to a recent change to default settings on newly created buckets. Following some hints from that Stack Overflow I was able resolve the problem by removing the PublicRead ACL and replacing with public access config and ownership controls:

diff --git a/bucket.yml b/bucket.yml
index c179569..7b43bb0 100644
--- a/bucket.yml
+++ b/bucket.yml
@@ -9,7 +9,14 @@ Resources:
     Type: AWS::S3::Bucket
     Properties:
       BucketName: !Sub "${MyBucketName}"
-      AccessControl: PublicRead
+      PublicAccessBlockConfiguration:
+        BlockPublicAcls: false
+        BlockPublicPolicy: false
+        IgnorePublicAcls: false
+        RestrictPublicBuckets: false
+      OwnershipControls:
+        Rules:
+          - ObjectOwnership: ObjectWriter
       WebsiteConfiguration:
         IndexDocument: index.html
         ErrorDocument: error.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant