aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap

Creating an S3 Bucket with "BucketOwnerEnforced" is not done atomically, causing a failure if BucketOwnerEnforced is enforced by an SCP

Open
#1,148 0 comments 1 reaction 0 assignees View on GitHub
Coverage NeedTriage
Dominant language
No language data
Stars
1.1k
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Name of the resource

AWS::S3::Bucket

### Resource name

_No response_

### Description

S3 recently introduced the BucketOwnerEnforced feature which enables creation of an S3 bucket with a flag that ensures all objects are owned by the bucket owner. Through AWS Organization's service control policies, customers now will want to prevent creation of any bucket that does NOT have BucketOwnerEnforced enabled. If a customer enables this SCP for their AWS account, this effectively disables bucket creation completely, even if one is explicitly creating a bucket with this flag. The reason for this is that CloudFormation applies the BucketOwnerEnforced option AFTER an S3 bucket is created, through the PutBucketOwnershipControls API.

My request is that the CloudFormation team applies the BucketOwnerEnforced option at bucket creation, and not after the fact. Otherwise, customers cannot create buckets if this feature is enabled.

### Other Details

Here is an example SCP that forces BucketOwnerEnforced to be applied at bucket creation time:

```
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyCreateModifyBucketWithACLs",
"Effect": "Deny",
"Action": [
"s3:CreateBucket",
"s3:PutBucketOwnershipControls"
],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"s3:x-amz-object-ownership": [
"BucketOwnerEnforced"
]
}
}
}
]
}
```

If the above SCP is applied to an account through AWS Organizations, it effectively disables bucket creation even if one specifies the option in CloudFormation:

```
AWSTemplateFormatVersion: "2010-09-09"
Resources:
RandomBucketName:
Type: AWS::S3::Bucket
Properties:
OwnershipControls:
Rules:
- ObjectOwnership: BucketOwnerEnforced
```

Contributor guide

Open the contributing guide

Research direction

Start with the AWS::S3::Bucket example and the documented OwnershipControls behavior, then reproduce the failure using the supplied SCP. Done means CloudFormation creates the bucket with BucketOwnerEnforced in the creation request so the SCP permits creation without a later ownership-controls call.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws
Domain
cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.