PutBucketOwnershipControls - Amazon Simple Storage Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

PutBucketOwnershipControls

Note

This operation is not supported for directory buckets.

Creates or modifies OwnershipControls for an Amazon S3 bucket. To use this operation, you must have the s3:PutBucketOwnershipControls permission. For more information about Amazon S3 permissions, see Specifying permissions in a policy.

For information about Amazon S3 Object Ownership, see Using object ownership.

The following operations are related to PutBucketOwnershipControls:

Request Syntax

PUT /?ownershipControls HTTP/1.1 Host: Bucket.s3.amazonaws.com Content-MD5: ContentMD5 x-amz-expected-bucket-owner: ExpectedBucketOwner <?xml version="1.0" encoding="UTF-8"?> <OwnershipControls xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Rule> <ObjectOwnership>string</ObjectOwnership> </Rule> ... </OwnershipControls>

URI Request Parameters

The request uses the following URI parameters.

Bucket

The name of the Amazon S3 bucket whose OwnershipControls you want to set.

Required: Yes

Content-MD5

The MD5 hash of the OwnershipControls request body.

For requests made using the Amazon Command Line Interface (CLI) or Amazon SDKs, this field is calculated automatically.

x-amz-expected-bucket-owner

The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

Request Body

The request accepts the following data in XML format.

OwnershipControls

Root level tag for the OwnershipControls parameters.

Required: Yes

Rule

The container element for an ownership control rule.

Type: Array of OwnershipControlsRule data types

Required: Yes

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Examples

Sample Request with BucketOwnerEnforced OwnershipControls

The following request puts a bucket OwnershipControls that specifies BucketOwnerEnforced.

PUT /amzn-s3-demo-bucket?ownershipControls= HTTP/1.1 Host:amzn-s3-demo-bucket.s3.<Region>.amazonaws.com x-amz-date: 20211130T230132Z x-amz-content-sha256: bafb46c18574a73704c8227aef060df1c12ea0d964e19b949d06e9f763805fe2 Authorization: authorization string <?xml version="1.0" encoding="UTF-8"?> <OwnershipControls xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Rule> <ObjectOwnership>BucketOwnerEnforced</ObjectOwnership> </Rule> </OwnershipControls>

Sample Response with BucketOwnerEnforced OwnershipControls

This example illustrates one usage of PutBucketOwnershipControls.

HTTP/1.1 200 OK x-amz-id-2: zkDVX0gbz8oKcjNz7GPz8XhXkhNArHtA8/WOf5hyEj6SbisSRdqITZvSuAMik7HK4PY+izDZZI0= x-amz-request-id: BK7Y8M3G7Z0RFRCP Date: Tue, 30 Nov 2021 23:01:33 GMT Content-Length: 0 Server: AmazonS3

Sample Request with BucketOwnerPreferred OwnershipControls

The following request puts a bucket OwnershipControls that specifies BucketOwnerPreferred.

PUT /amzn-s3-demo-bucket?ownershipControls= HTTP/1.1 Host:amzn-s3-demo-bucket.s3.<Region>.amazonaws.com x-amz-date: 20200618T230132Z x-amz-content-sha256: bafb46c18574a73704c8227aef060df1c12ea0d964e19b949d06e9f763805fe2 Authorization: authorization string <?xml version="1.0" encoding="UTF-8"?> <OwnershipControls xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Rule> <ObjectOwnership>BucketOwnerPreferred</ObjectOwnership> </Rule> </OwnershipControls>

Sample Response with BucketOwnerPreferred OwnershipControls

This example illustrates one usage of PutBucketOwnershipControls.

HTTP/1.1 200 OK x-amz-id-2: zkDVX0gbz8oKcjNz7GPz8XhXkhNArHtA8/WOf5hyEj6SbisSRdqITZvSuAMik7HK4PY+izDZZI0= x-amz-request-id: BK7Y8M3G7Z0RFRCP Date: Thu, 18 Jun 2020 23:01:33 GMT Content-Length: 0 Server: AmazonS3

Sample Request with ObjectWriter OwnershipControls

The following request puts a bucket OwnershipControls that specifies ObjectWriter.

PUT /amzn-s3-demo-bucket?ownershipControls= HTTP/1.1 Host:amzn-s3-demo-bucket.s3.<Region>.amazonaws.com x-amz-date: 20200618T230132Z x-amz-content-sha256: bafb46c18574a73704c8227aef060df1c12ea0d964e19b949d06e9f763805fe2 Authorization: authorization string <?xml version="1.0" encoding="UTF-8"?> <OwnershipControls xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Rule> <ObjectOwnership>ObjectWriter</ObjectOwnership> </Rule> </OwnershipControls>

Sample Response with ObjectWriter OwnershipControls

This example illustrates one usage of PutBucketOwnershipControls.

HTTP/1.1 200 OK x-amz-id-2: zkDVX0gbz8oKcjNz7GPz8XhXkhNArHtA8/WOf5hyEj6SbisSRdqITZvSuAMik7HK4PY+izDZZI0= x-amz-request-id: BK7Y8M3G7Z0RFRCP Date: Thu, 18 Jun 2020 23:01:33 GMT Content-Length: 0 Server: AmazonS3

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: