1. Packages
  2. AWS
  3. API Docs
  4. s3
  5. BucketOwnershipControls
AWS v6.77.0 published on Wednesday, Apr 9, 2025 by Pulumi

aws.s3.BucketOwnershipControls

Explore with Pulumi AI

Provides a resource to manage S3 Bucket Ownership Controls. For more information, see the S3 Developer Guide.

This resource cannot be used with S3 directory buckets.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.s3.BucketV2("example", {bucket: "example"});
const exampleBucketOwnershipControls = new aws.s3.BucketOwnershipControls("example", {
    bucket: example.id,
    rule: {
        objectOwnership: "BucketOwnerPreferred",
    },
});
Copy
import pulumi
import pulumi_aws as aws

example = aws.s3.BucketV2("example", bucket="example")
example_bucket_ownership_controls = aws.s3.BucketOwnershipControls("example",
    bucket=example.id,
    rule={
        "object_ownership": "BucketOwnerPreferred",
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
			Bucket: pulumi.String("example"),
		})
		if err != nil {
			return err
		}
		_, err = s3.NewBucketOwnershipControls(ctx, "example", &s3.BucketOwnershipControlsArgs{
			Bucket: example.ID(),
			Rule: &s3.BucketOwnershipControlsRuleArgs{
				ObjectOwnership: pulumi.String("BucketOwnerPreferred"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.S3.BucketV2("example", new()
    {
        Bucket = "example",
    });

    var exampleBucketOwnershipControls = new Aws.S3.BucketOwnershipControls("example", new()
    {
        Bucket = example.Id,
        Rule = new Aws.S3.Inputs.BucketOwnershipControlsRuleArgs
        {
            ObjectOwnership = "BucketOwnerPreferred",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.s3.BucketV2Args;
import com.pulumi.aws.s3.BucketOwnershipControls;
import com.pulumi.aws.s3.BucketOwnershipControlsArgs;
import com.pulumi.aws.s3.inputs.BucketOwnershipControlsRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new BucketV2("example", BucketV2Args.builder()
            .bucket("example")
            .build());

        var exampleBucketOwnershipControls = new BucketOwnershipControls("exampleBucketOwnershipControls", BucketOwnershipControlsArgs.builder()
            .bucket(example.id())
            .rule(BucketOwnershipControlsRuleArgs.builder()
                .objectOwnership("BucketOwnerPreferred")
                .build())
            .build());

    }
}
Copy
resources:
  example:
    type: aws:s3:BucketV2
    properties:
      bucket: example
  exampleBucketOwnershipControls:
    type: aws:s3:BucketOwnershipControls
    name: example
    properties:
      bucket: ${example.id}
      rule:
        objectOwnership: BucketOwnerPreferred
Copy

Create BucketOwnershipControls Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new BucketOwnershipControls(name: string, args: BucketOwnershipControlsArgs, opts?: CustomResourceOptions);
@overload
def BucketOwnershipControls(resource_name: str,
                            args: BucketOwnershipControlsArgs,
                            opts: Optional[ResourceOptions] = None)

@overload
def BucketOwnershipControls(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            bucket: Optional[str] = None,
                            rule: Optional[BucketOwnershipControlsRuleArgs] = None)
func NewBucketOwnershipControls(ctx *Context, name string, args BucketOwnershipControlsArgs, opts ...ResourceOption) (*BucketOwnershipControls, error)
public BucketOwnershipControls(string name, BucketOwnershipControlsArgs args, CustomResourceOptions? opts = null)
public BucketOwnershipControls(String name, BucketOwnershipControlsArgs args)
public BucketOwnershipControls(String name, BucketOwnershipControlsArgs args, CustomResourceOptions options)
type: aws:s3:BucketOwnershipControls
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. BucketOwnershipControlsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. BucketOwnershipControlsArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. BucketOwnershipControlsArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. BucketOwnershipControlsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. BucketOwnershipControlsArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var bucketOwnershipControlsResource = new Aws.S3.BucketOwnershipControls("bucketOwnershipControlsResource", new()
{
    Bucket = "string",
    Rule = new Aws.S3.Inputs.BucketOwnershipControlsRuleArgs
    {
        ObjectOwnership = "string",
    },
});
Copy
example, err := s3.NewBucketOwnershipControls(ctx, "bucketOwnershipControlsResource", &s3.BucketOwnershipControlsArgs{
	Bucket: pulumi.String("string"),
	Rule: &s3.BucketOwnershipControlsRuleArgs{
		ObjectOwnership: pulumi.String("string"),
	},
})
Copy
var bucketOwnershipControlsResource = new BucketOwnershipControls("bucketOwnershipControlsResource", BucketOwnershipControlsArgs.builder()
    .bucket("string")
    .rule(BucketOwnershipControlsRuleArgs.builder()
        .objectOwnership("string")
        .build())
    .build());
Copy
bucket_ownership_controls_resource = aws.s3.BucketOwnershipControls("bucketOwnershipControlsResource",
    bucket="string",
    rule={
        "object_ownership": "string",
    })
Copy
const bucketOwnershipControlsResource = new aws.s3.BucketOwnershipControls("bucketOwnershipControlsResource", {
    bucket: "string",
    rule: {
        objectOwnership: "string",
    },
});
Copy
type: aws:s3:BucketOwnershipControls
properties:
    bucket: string
    rule:
        objectOwnership: string
Copy

BucketOwnershipControls Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The BucketOwnershipControls resource accepts the following input properties:

Bucket
This property is required.
Changes to this property will trigger replacement.
string
Name of the bucket that you want to associate this access point with.
Rule This property is required. BucketOwnershipControlsRule
Configuration block(s) with Ownership Controls rules. Detailed below.
Bucket
This property is required.
Changes to this property will trigger replacement.
string
Name of the bucket that you want to associate this access point with.
Rule This property is required. BucketOwnershipControlsRuleArgs
Configuration block(s) with Ownership Controls rules. Detailed below.
bucket
This property is required.
Changes to this property will trigger replacement.
String
Name of the bucket that you want to associate this access point with.
rule This property is required. BucketOwnershipControlsRule
Configuration block(s) with Ownership Controls rules. Detailed below.
bucket
This property is required.
Changes to this property will trigger replacement.
string
Name of the bucket that you want to associate this access point with.
rule This property is required. BucketOwnershipControlsRule
Configuration block(s) with Ownership Controls rules. Detailed below.
bucket
This property is required.
Changes to this property will trigger replacement.
str
Name of the bucket that you want to associate this access point with.
rule This property is required. BucketOwnershipControlsRuleArgs
Configuration block(s) with Ownership Controls rules. Detailed below.
bucket
This property is required.
Changes to this property will trigger replacement.
String
Name of the bucket that you want to associate this access point with.
rule This property is required. Property Map
Configuration block(s) with Ownership Controls rules. Detailed below.

Outputs

All input properties are implicitly available as output properties. Additionally, the BucketOwnershipControls resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing BucketOwnershipControls Resource

Get an existing BucketOwnershipControls resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: BucketOwnershipControlsState, opts?: CustomResourceOptions): BucketOwnershipControls
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        bucket: Optional[str] = None,
        rule: Optional[BucketOwnershipControlsRuleArgs] = None) -> BucketOwnershipControls
func GetBucketOwnershipControls(ctx *Context, name string, id IDInput, state *BucketOwnershipControlsState, opts ...ResourceOption) (*BucketOwnershipControls, error)
public static BucketOwnershipControls Get(string name, Input<string> id, BucketOwnershipControlsState? state, CustomResourceOptions? opts = null)
public static BucketOwnershipControls get(String name, Output<String> id, BucketOwnershipControlsState state, CustomResourceOptions options)
resources:  _:    type: aws:s3:BucketOwnershipControls    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Bucket Changes to this property will trigger replacement. string
Name of the bucket that you want to associate this access point with.
Rule BucketOwnershipControlsRule
Configuration block(s) with Ownership Controls rules. Detailed below.
Bucket Changes to this property will trigger replacement. string
Name of the bucket that you want to associate this access point with.
Rule BucketOwnershipControlsRuleArgs
Configuration block(s) with Ownership Controls rules. Detailed below.
bucket Changes to this property will trigger replacement. String
Name of the bucket that you want to associate this access point with.
rule BucketOwnershipControlsRule
Configuration block(s) with Ownership Controls rules. Detailed below.
bucket Changes to this property will trigger replacement. string
Name of the bucket that you want to associate this access point with.
rule BucketOwnershipControlsRule
Configuration block(s) with Ownership Controls rules. Detailed below.
bucket Changes to this property will trigger replacement. str
Name of the bucket that you want to associate this access point with.
rule BucketOwnershipControlsRuleArgs
Configuration block(s) with Ownership Controls rules. Detailed below.
bucket Changes to this property will trigger replacement. String
Name of the bucket that you want to associate this access point with.
rule Property Map
Configuration block(s) with Ownership Controls rules. Detailed below.

Supporting Types

BucketOwnershipControlsRule
, BucketOwnershipControlsRuleArgs

ObjectOwnership This property is required. string
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.
ObjectOwnership This property is required. string
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.
objectOwnership This property is required. String
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.
objectOwnership This property is required. string
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.
object_ownership This property is required. str
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.
objectOwnership This property is required. String
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.

Import

Using pulumi import, import S3 Bucket Ownership Controls using S3 Bucket name. For example:

$ pulumi import aws:s3/bucketOwnershipControls:BucketOwnershipControls example my-bucket
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.