-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
aws-s3: Unable to Disable ACLs for Access Log Bucket #26832
Comments
Thanks for reaching out @kristian-d. Using bucket policy is the recommended approach in our docs to enable server access logging -
Also here is another reference of the suggestion in our docs for allowing access log delivery using a Bucket Policy. With that being said, it would be helpful to understand your usecase. Could you please elaborate your usecase for better understanding. Thanks |
@kristian-d this was fixed a while back in this PR; it requires a feature flag to be set in your "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true, |
@peterwoodworth Thanks! I've confirmed that the flag worked as intended for my use case. I missed this option in the documentation. For others finding this thread in the future, the context's feature flag is described here. I do think the suggestion from @kylelaker in the linked PR
(and from myself above) would be worth reconsideration as it would avoid an explicitly defined feature flag and better facilitate best practices. |
Yes this makes sense @kristian-d, thanks for the feedback 🙂 I think this didn't happen due to what this comment refers to about this PR. If this isn't true then we could reconsider |
From my understanding of that thread and its linked PR, the problem was caused by updating S3 access log bucket default configurations to exclude A solution that conditionally avoids setting |
This makes sense to me - we'd be willing to accept a contribution for this @kristian-d, assuming I'm not missing anything else |
Describe the bug
General S3 best practices now recommend that bucket ACLs be disabled, leading bucket ownership controls to be configured as
BUCKET_OWNER_ENFORCED
.While I can successfully attach a bucket policy to an access log bucket that grants
logging.s3.amazonaws.com
withs3:PutObject
permissions per this documentation, I am unable to set that access log bucket's ownership toBUCKET_OWNER_ENFORCED
. S3 throws an exception during bucket creation and modification because CDK automatically sets the bucket'sAccessControl
toLogDeliveryWrite
when it is provided to another bucket'sserverAccessLogsBucket
property.Expected Behavior
Bucket creation and modification succeeds for an access log bucket with ownership controls set to
BUCKET_OWNER_ENFORCED
.Current Behavior
Bucket creation and modification fails with
for an access log bucket with ownership controls set to
BUCKET_OWNER_ENFORCED
.Reproduction Steps
Possible Solution
A potential backward compatible change would check whether a bucket's
BUCKET_OWNER_ENFORCED
property disables ACLs for a bucket prior to automatically settingAccessControl
toLogDeliveryWrite
when that bucket is provided toserverAccessLogsBucket
. If ACLs are disabled,AccessControl
would be ignored and the customer would need to add a bucket policy providinglogging.s3.amazonaws.com
withs3:PutObject
permissions.Alternatively, we may be able to expose a bucket's logging configuration to allow for manually setting the access log bucket.
Additional Information/Context
No response
CDK CLI Version
2.91.0
Framework Version
No response
Node.js Version
v14.21.3
OS
Linux
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: