Skip to content

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

Description

@LichP

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions