# ObjectOwnership

The ObjectOwnership of the bucket.

- Source: [`aws-s3/lib/bucket.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-s3/lib/bucket.ts#L1461)
- Type last changed: v2.2.0 · 15 Dec 2021

## Example

```ts
const accessLogsBucket = new s3.Bucket(this, 'AccessLogsBucket', {
  objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_ENFORCED,
});

accessLogsBucket.addToResourcePolicy(
  new iam.PolicyStatement({
    actions: ['s3:*'],
    resources: [accessLogsBucket.bucketArn, accessLogsBucket.arnForObjects('*')],
    principals: [new iam.AnyPrincipal()],
  })
)

const bucket = new s3.Bucket(this, 'MyBucket', {
  serverAccessLogsBucket: accessLogsBucket,
  serverAccessLogsPrefix: 'logs',
});
```

## Members

| Member | Description |
| --- | --- |
| `BUCKET_OWNER_ENFORCED` | ACLs are disabled, and the bucket owner automatically owns and has full control over every object in the bucket. |
| `BUCKET_OWNER_PREFERRED` | The bucket owner will own the object if the object is uploaded with the bucket-owner-full-control canned ACL. |
| `OBJECT_WRITER` | The uploading account will own the object. |

## Referenced by

- [`BucketBase`](/v2/docs/aws-cdk-lib.aws_s3.BucketBase).objectOwnership
- [`BucketProps`](/v2/docs/aws-cdk-lib.aws_s3.BucketProps).objectOwnership
