Using SAM and trying to get a private bucket up and keeps failing with “The bucket does not allow ACLs “
UploadBucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Ref BucketName
# Block 1 - tried by itself and in combo with other blocks
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false # or true - doesn't make a diff
IgnorePublicAcls: false
RestrictPublicBuckets: false
# Block 2 - tried by itself and in combo with other blocks
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerEnforced
# Block 3 - tried by itself and in combo with other blocks
UploadBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref UploadBucket
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:ListBucket
Resource:
- !Sub arn:aws:s3:::${BucketName}
Principal:
AWS:
- !Sub arn:aws:iam::${AWS::AccountId}:root
- Effect: Allow
Action:
- s3:*Object"
Resource:
- !Sub arn:aws:s3:::${BucketName}/*
Principal:
AWS:
- !Sub arn:aws:iam::${AWS::AccountId}:root
I’ve read soooo many posts on this and the only working solution seems to be to force enable ACL which I am trying not to resort to. The example templates for S3 in the SAM directory do no work either.
Most answers just give up and enable ACL. Some suggest that this block would do the trick but it does not.
PublicAccessBlockConfiguration:
BlockPublicAcls: false
BlockPublicPolicy: false # Will allow the creation of the policy
IgnorePublicAcls: false
RestrictPublicBuckets: false
Any idea? I’d love an example of a working stack.