Provides a resource to manage S3 Bucket Ownership Controls. For more information, see the S3 Developer Guide.
resource "aws_s3_bucket" "example" {
bucket = "example"
}
resource "aws_s3_bucket_ownership_controls" "example" {
bucket = aws_s3_bucket.example.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}
The following arguments are required:
bucket
- (Required) Name of the bucket that you want to associate this access point with.rule
- (Required) Configuration block(s) with Ownership Controls rules. Detailed below.The following arguments are required:
object_ownership
- (Required) Object ownership. Valid values: BucketOwnerPreferred
, ObjectWriter
or BucketOwnerEnforced
BucketOwnerPreferred
- Objects uploaded to the bucket change ownership to the bucket owner if the objects are uploaded with the bucket-owner-full-control
canned ACL.ObjectWriter
- Uploading account will own the object if the object is uploaded with the bucket-owner-full-control
canned ACL.BucketOwnerEnforced
- Bucket owner automatically owns and has full control over every object in the bucket. ACLs no longer affect permissions to data in the S3 bucket.This resource exports the following attributes in addition to the arguments above:
id
- S3 Bucket name.In Terraform v1.5.0 and later, use an import
block to import S3 Bucket Ownership Controls using S3 Bucket name. For example:
import {
to = aws_s3_bucket_ownership_controls.example
id = "my-bucket"
}
Using terraform import
, import S3 Bucket Ownership Controls using S3 Bucket name. For example:
% terraform import aws_s3_bucket_ownership_controls.example my-bucket