amazon-api-gateway-url-shortener icon indicating copy to clipboard operation
amazon-api-gateway-url-shortener copied to clipboard

fix(template.yaml): enable ACLs on cloudfront logging bucket and add bucket policy

Open ivancasco opened this issue 1 year ago • 1 comments

Description of changes: This Pull Request updates the configuration for the S3 bucket used to store CloudFront access logs. The changes ensure compatibility with AWS’s 2023 updates, where ACLs are disabled by default on new S3 buckets.

Without these updates, the stack no longer deploys, as it shows the following error: Invalid request provided: AWS::CloudFront::Distribution:The S3 bucket that you specified for CloudFront logs does not enable ACL access:

Changes Introduced:

  • Enable ACLs:
    • Added ObjectOwnership: BucketOwnerPreferred to ensure all objects in the bucket are owned by the bucket owner, regardless of the uploader. This enables the ACLs on the bucket.
  • Access Control:
    • Added AccessControl: LogDeliveryWrite to allow CloudFront to write access logs to the bucket.
  • Bucket Policy:
    • Granted s3:PutObject permissions to the cloudfront.amazonaws.com service principal for log delivery.
    • Granted s3:GetBucketAcl and s3:PutBucketAcl permissions to cloudfront.amazonaws.com to manage ACLs as required.

Reference:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ivancasco avatar Dec 19 '24 22:12 ivancasco

I've run into the error Invalid request provided: AWS::CloudFront::Distribution:The S3 bucket that you specified for CloudFront logs does not enable ACL access and tried deploying this branch and still get the same error during deployment.

namelessmasses avatar Jan 08 '25 09:01 namelessmasses

Confirming this solved the problem for me

chris-denning avatar Oct 26 '25 09:10 chris-denning