1. Packages
  2. AWS
  3. API Docs
  4. s3
  5. BucketObjectLockConfigurationV2
Viewing docs for AWS v5.43.0 (Older version)
published on Tuesday, Mar 10, 2026 by Pulumi
aws logo
Viewing docs for AWS v5.43.0 (Older version)
published on Tuesday, Mar 10, 2026 by Pulumi

    Provides an S3 bucket Object Lock configuration resource. For more information about Object Locking, go to Using S3 Object Lock in the Amazon S3 User Guide.

    NOTE: This resource does not enable Object Lock for new buckets. It configures a default retention period for objects placed in the specified bucket. Thus, to enable Object Lock for a new bucket, see the Using object lock configuration section in the aws.s3.BucketV2 resource or the Object Lock configuration for a new bucket example below. If you want to enable Object Lock for an existing bucket, contact AWS Support and see the Object Lock configuration for an existing bucket example below.

    Example Usage

    Object Lock configuration for a new bucket

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleBucketV2 = new Aws.S3.BucketV2("exampleBucketV2", new()
        {
            ObjectLockEnabled = true,
        });
    
        var exampleBucketObjectLockConfigurationV2 = new Aws.S3.BucketObjectLockConfigurationV2("exampleBucketObjectLockConfigurationV2", new()
        {
            Bucket = exampleBucketV2.Id,
            Rule = new Aws.S3.Inputs.BucketObjectLockConfigurationV2RuleArgs
            {
                DefaultRetention = new Aws.S3.Inputs.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs
                {
                    Mode = "COMPLIANCE",
                    Days = 5,
                },
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleBucketV2, err := s3.NewBucketV2(ctx, "exampleBucketV2", &s3.BucketV2Args{
    			ObjectLockEnabled: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = s3.NewBucketObjectLockConfigurationV2(ctx, "exampleBucketObjectLockConfigurationV2", &s3.BucketObjectLockConfigurationV2Args{
    			Bucket: exampleBucketV2.ID(),
    			Rule: &s3.BucketObjectLockConfigurationV2RuleArgs{
    				DefaultRetention: &s3.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs{
    					Mode: pulumi.String("COMPLIANCE"),
    					Days: pulumi.Int(5),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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.BucketObjectLockConfigurationV2;
    import com.pulumi.aws.s3.BucketObjectLockConfigurationV2Args;
    import com.pulumi.aws.s3.inputs.BucketObjectLockConfigurationV2RuleArgs;
    import com.pulumi.aws.s3.inputs.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs;
    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 exampleBucketV2 = new BucketV2("exampleBucketV2", BucketV2Args.builder()        
                .objectLockEnabled(true)
                .build());
    
            var exampleBucketObjectLockConfigurationV2 = new BucketObjectLockConfigurationV2("exampleBucketObjectLockConfigurationV2", BucketObjectLockConfigurationV2Args.builder()        
                .bucket(exampleBucketV2.id())
                .rule(BucketObjectLockConfigurationV2RuleArgs.builder()
                    .defaultRetention(BucketObjectLockConfigurationV2RuleDefaultRetentionArgs.builder()
                        .mode("COMPLIANCE")
                        .days(5)
                        .build())
                    .build())
                .build());
    
        }
    }
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const exampleBucketV2 = new aws.s3.BucketV2("exampleBucketV2", {objectLockEnabled: true});
    const exampleBucketObjectLockConfigurationV2 = new aws.s3.BucketObjectLockConfigurationV2("exampleBucketObjectLockConfigurationV2", {
        bucket: exampleBucketV2.id,
        rule: {
            defaultRetention: {
                mode: "COMPLIANCE",
                days: 5,
            },
        },
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example_bucket_v2 = aws.s3.BucketV2("exampleBucketV2", object_lock_enabled=True)
    example_bucket_object_lock_configuration_v2 = aws.s3.BucketObjectLockConfigurationV2("exampleBucketObjectLockConfigurationV2",
        bucket=example_bucket_v2.id,
        rule=aws.s3.BucketObjectLockConfigurationV2RuleArgs(
            default_retention=aws.s3.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs(
                mode="COMPLIANCE",
                days=5,
            ),
        ))
    
    resources:
      exampleBucketV2:
        type: aws:s3:BucketV2
        properties:
          objectLockEnabled: true
      exampleBucketObjectLockConfigurationV2:
        type: aws:s3:BucketObjectLockConfigurationV2
        properties:
          bucket: ${exampleBucketV2.id}
          rule:
            defaultRetention:
              mode: COMPLIANCE
              days: 5
    

    Object Lock configuration for an existing bucket

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleBucketV2 = new Aws.S3.BucketV2("exampleBucketV2");
    
        var exampleBucketVersioningV2 = new Aws.S3.BucketVersioningV2("exampleBucketVersioningV2", new()
        {
            Bucket = exampleBucketV2.Id,
            VersioningConfiguration = new Aws.S3.Inputs.BucketVersioningV2VersioningConfigurationArgs
            {
                Status = "Enabled",
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleBucketV2, err := s3.NewBucketV2(ctx, "exampleBucketV2", nil)
    		if err != nil {
    			return err
    		}
    		_, err = s3.NewBucketVersioningV2(ctx, "exampleBucketVersioningV2", &s3.BucketVersioningV2Args{
    			Bucket: exampleBucketV2.ID(),
    			VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{
    				Status: pulumi.String("Enabled"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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.BucketVersioningV2;
    import com.pulumi.aws.s3.BucketVersioningV2Args;
    import com.pulumi.aws.s3.inputs.BucketVersioningV2VersioningConfigurationArgs;
    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 exampleBucketV2 = new BucketV2("exampleBucketV2");
    
            var exampleBucketVersioningV2 = new BucketVersioningV2("exampleBucketVersioningV2", BucketVersioningV2Args.builder()        
                .bucket(exampleBucketV2.id())
                .versioningConfiguration(BucketVersioningV2VersioningConfigurationArgs.builder()
                    .status("Enabled")
                    .build())
                .build());
    
        }
    }
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const exampleBucketV2 = new aws.s3.BucketV2("exampleBucketV2", {});
    const exampleBucketVersioningV2 = new aws.s3.BucketVersioningV2("exampleBucketVersioningV2", {
        bucket: exampleBucketV2.id,
        versioningConfiguration: {
            status: "Enabled",
        },
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example_bucket_v2 = aws.s3.BucketV2("exampleBucketV2")
    example_bucket_versioning_v2 = aws.s3.BucketVersioningV2("exampleBucketVersioningV2",
        bucket=example_bucket_v2.id,
        versioning_configuration=aws.s3.BucketVersioningV2VersioningConfigurationArgs(
            status="Enabled",
        ))
    
    resources:
      exampleBucketV2:
        type: aws:s3:BucketV2
      exampleBucketVersioningV2:
        type: aws:s3:BucketVersioningV2
        properties:
          bucket: ${exampleBucketV2.id}
          versioningConfiguration:
            status: Enabled
    

    .

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Aws.S3.BucketObjectLockConfigurationV2("example", new()
        {
            Bucket = aws_s3_bucket.Example.Id,
            Rule = new Aws.S3.Inputs.BucketObjectLockConfigurationV2RuleArgs
            {
                DefaultRetention = new Aws.S3.Inputs.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs
                {
                    Mode = "COMPLIANCE",
                    Days = 5,
                },
            },
            Token = "NG2MKsfoLqV3A+aquXneSG4LOu/ekrlXkRXwIPFVfERT7XOPos+/k444d7RIH0E3W3p5QU6ml2exS2F/eYCFmMWHJ3hFZGk6al1sIJkmNhUMYmsv0jYVQyTTZNLM+DnfooA6SATt39mM1VW1yJh4E+XljMlWzaBwHKbss3/EjlGDjOmVhaSs4Z6427mMCaFD0RLwsYY7zX49gEc31YfOMJGxbXCXSeyNwAhhM/A8UH7gQf38RmjHjjAFbbbLtl8arsxTPW8F1IYohqwmKIr9DnotLLj8Tg44U2SPwujVaqmlKKP9s41rfgb4UbIm7khSafDBng0LGfxC4pMlT9Ny2w==",
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := s3.NewBucketObjectLockConfigurationV2(ctx, "example", &s3.BucketObjectLockConfigurationV2Args{
    			Bucket: pulumi.Any(aws_s3_bucket.Example.Id),
    			Rule: &s3.BucketObjectLockConfigurationV2RuleArgs{
    				DefaultRetention: &s3.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs{
    					Mode: pulumi.String("COMPLIANCE"),
    					Days: pulumi.Int(5),
    				},
    			},
    			Token: pulumi.String("NG2MKsfoLqV3A+aquXneSG4LOu/ekrlXkRXwIPFVfERT7XOPos+/k444d7RIH0E3W3p5QU6ml2exS2F/eYCFmMWHJ3hFZGk6al1sIJkmNhUMYmsv0jYVQyTTZNLM+DnfooA6SATt39mM1VW1yJh4E+XljMlWzaBwHKbss3/EjlGDjOmVhaSs4Z6427mMCaFD0RLwsYY7zX49gEc31YfOMJGxbXCXSeyNwAhhM/A8UH7gQf38RmjHjjAFbbbLtl8arsxTPW8F1IYohqwmKIr9DnotLLj8Tg44U2SPwujVaqmlKKP9s41rfgb4UbIm7khSafDBng0LGfxC4pMlT9Ny2w=="),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.s3.BucketObjectLockConfigurationV2;
    import com.pulumi.aws.s3.BucketObjectLockConfigurationV2Args;
    import com.pulumi.aws.s3.inputs.BucketObjectLockConfigurationV2RuleArgs;
    import com.pulumi.aws.s3.inputs.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs;
    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 BucketObjectLockConfigurationV2("example", BucketObjectLockConfigurationV2Args.builder()        
                .bucket(aws_s3_bucket.example().id())
                .rule(BucketObjectLockConfigurationV2RuleArgs.builder()
                    .defaultRetention(BucketObjectLockConfigurationV2RuleDefaultRetentionArgs.builder()
                        .mode("COMPLIANCE")
                        .days(5)
                        .build())
                    .build())
                .token("NG2MKsfoLqV3A+aquXneSG4LOu/ekrlXkRXwIPFVfERT7XOPos+/k444d7RIH0E3W3p5QU6ml2exS2F/eYCFmMWHJ3hFZGk6al1sIJkmNhUMYmsv0jYVQyTTZNLM+DnfooA6SATt39mM1VW1yJh4E+XljMlWzaBwHKbss3/EjlGDjOmVhaSs4Z6427mMCaFD0RLwsYY7zX49gEc31YfOMJGxbXCXSeyNwAhhM/A8UH7gQf38RmjHjjAFbbbLtl8arsxTPW8F1IYohqwmKIr9DnotLLj8Tg44U2SPwujVaqmlKKP9s41rfgb4UbIm7khSafDBng0LGfxC4pMlT9Ny2w==")
                .build());
    
        }
    }
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.s3.BucketObjectLockConfigurationV2("example", {
        bucket: aws_s3_bucket.example.id,
        rule: {
            defaultRetention: {
                mode: "COMPLIANCE",
                days: 5,
            },
        },
        token: "NG2MKsfoLqV3A+aquXneSG4LOu/ekrlXkRXwIPFVfERT7XOPos+/k444d7RIH0E3W3p5QU6ml2exS2F/eYCFmMWHJ3hFZGk6al1sIJkmNhUMYmsv0jYVQyTTZNLM+DnfooA6SATt39mM1VW1yJh4E+XljMlWzaBwHKbss3/EjlGDjOmVhaSs4Z6427mMCaFD0RLwsYY7zX49gEc31YfOMJGxbXCXSeyNwAhhM/A8UH7gQf38RmjHjjAFbbbLtl8arsxTPW8F1IYohqwmKIr9DnotLLj8Tg44U2SPwujVaqmlKKP9s41rfgb4UbIm7khSafDBng0LGfxC4pMlT9Ny2w==",
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.s3.BucketObjectLockConfigurationV2("example",
        bucket=aws_s3_bucket["example"]["id"],
        rule=aws.s3.BucketObjectLockConfigurationV2RuleArgs(
            default_retention=aws.s3.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs(
                mode="COMPLIANCE",
                days=5,
            ),
        ),
        token="NG2MKsfoLqV3A+aquXneSG4LOu/ekrlXkRXwIPFVfERT7XOPos+/k444d7RIH0E3W3p5QU6ml2exS2F/eYCFmMWHJ3hFZGk6al1sIJkmNhUMYmsv0jYVQyTTZNLM+DnfooA6SATt39mM1VW1yJh4E+XljMlWzaBwHKbss3/EjlGDjOmVhaSs4Z6427mMCaFD0RLwsYY7zX49gEc31YfOMJGxbXCXSeyNwAhhM/A8UH7gQf38RmjHjjAFbbbLtl8arsxTPW8F1IYohqwmKIr9DnotLLj8Tg44U2SPwujVaqmlKKP9s41rfgb4UbIm7khSafDBng0LGfxC4pMlT9Ny2w==")
    
    resources:
      example:
        type: aws:s3:BucketObjectLockConfigurationV2
        properties:
          bucket: ${aws_s3_bucket.example.id}
          rule:
            defaultRetention:
              mode: COMPLIANCE
              days: 5
          token: NG2MKsfoLqV3A+aquXneSG4LOu/ekrlXkRXwIPFVfERT7XOPos+/k444d7RIH0E3W3p5QU6ml2exS2F/eYCFmMWHJ3hFZGk6al1sIJkmNhUMYmsv0jYVQyTTZNLM+DnfooA6SATt39mM1VW1yJh4E+XljMlWzaBwHKbss3/EjlGDjOmVhaSs4Z6427mMCaFD0RLwsYY7zX49gEc31YfOMJGxbXCXSeyNwAhhM/A8UH7gQf38RmjHjjAFbbbLtl8arsxTPW8F1IYohqwmKIr9DnotLLj8Tg44U2SPwujVaqmlKKP9s41rfgb4UbIm7khSafDBng0LGfxC4pMlT9Ny2w==
    

    Create BucketObjectLockConfigurationV2 Resource

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

    Constructor syntax

    new BucketObjectLockConfigurationV2(name: string, args: BucketObjectLockConfigurationV2Args, opts?: CustomResourceOptions);
    @overload
    def BucketObjectLockConfigurationV2(resource_name: str,
                                        args: BucketObjectLockConfigurationV2Args,
                                        opts: Optional[ResourceOptions] = None)
    
    @overload
    def BucketObjectLockConfigurationV2(resource_name: str,
                                        opts: Optional[ResourceOptions] = None,
                                        bucket: Optional[str] = None,
                                        expected_bucket_owner: Optional[str] = None,
                                        object_lock_enabled: Optional[str] = None,
                                        rule: Optional[BucketObjectLockConfigurationV2RuleArgs] = None,
                                        token: Optional[str] = None)
    func NewBucketObjectLockConfigurationV2(ctx *Context, name string, args BucketObjectLockConfigurationV2Args, opts ...ResourceOption) (*BucketObjectLockConfigurationV2, error)
    public BucketObjectLockConfigurationV2(string name, BucketObjectLockConfigurationV2Args args, CustomResourceOptions? opts = null)
    public BucketObjectLockConfigurationV2(String name, BucketObjectLockConfigurationV2Args args)
    public BucketObjectLockConfigurationV2(String name, BucketObjectLockConfigurationV2Args args, CustomResourceOptions options)
    
    type: aws:s3:BucketObjectLockConfigurationV2
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args BucketObjectLockConfigurationV2Args
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args BucketObjectLockConfigurationV2Args
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args BucketObjectLockConfigurationV2Args
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args BucketObjectLockConfigurationV2Args
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args BucketObjectLockConfigurationV2Args
    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 bucketObjectLockConfigurationV2Resource = new Aws.S3.BucketObjectLockConfigurationV2("bucketObjectLockConfigurationV2Resource", new()
    {
        Bucket = "string",
        ExpectedBucketOwner = "string",
        ObjectLockEnabled = "string",
        Rule = new Aws.S3.Inputs.BucketObjectLockConfigurationV2RuleArgs
        {
            DefaultRetention = new Aws.S3.Inputs.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs
            {
                Days = 0,
                Mode = "string",
                Years = 0,
            },
        },
        Token = "string",
    });
    
    example, err := s3.NewBucketObjectLockConfigurationV2(ctx, "bucketObjectLockConfigurationV2Resource", &s3.BucketObjectLockConfigurationV2Args{
    	Bucket:              pulumi.String("string"),
    	ExpectedBucketOwner: pulumi.String("string"),
    	ObjectLockEnabled:   pulumi.String("string"),
    	Rule: &s3.BucketObjectLockConfigurationV2RuleArgs{
    		DefaultRetention: &s3.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs{
    			Days:  pulumi.Int(0),
    			Mode:  pulumi.String("string"),
    			Years: pulumi.Int(0),
    		},
    	},
    	Token: pulumi.String("string"),
    })
    
    var bucketObjectLockConfigurationV2Resource = new BucketObjectLockConfigurationV2("bucketObjectLockConfigurationV2Resource", BucketObjectLockConfigurationV2Args.builder()
        .bucket("string")
        .expectedBucketOwner("string")
        .objectLockEnabled("string")
        .rule(BucketObjectLockConfigurationV2RuleArgs.builder()
            .defaultRetention(BucketObjectLockConfigurationV2RuleDefaultRetentionArgs.builder()
                .days(0)
                .mode("string")
                .years(0)
                .build())
            .build())
        .token("string")
        .build());
    
    bucket_object_lock_configuration_v2_resource = aws.s3.BucketObjectLockConfigurationV2("bucketObjectLockConfigurationV2Resource",
        bucket="string",
        expected_bucket_owner="string",
        object_lock_enabled="string",
        rule={
            "default_retention": {
                "days": 0,
                "mode": "string",
                "years": 0,
            },
        },
        token="string")
    
    const bucketObjectLockConfigurationV2Resource = new aws.s3.BucketObjectLockConfigurationV2("bucketObjectLockConfigurationV2Resource", {
        bucket: "string",
        expectedBucketOwner: "string",
        objectLockEnabled: "string",
        rule: {
            defaultRetention: {
                days: 0,
                mode: "string",
                years: 0,
            },
        },
        token: "string",
    });
    
    type: aws:s3:BucketObjectLockConfigurationV2
    properties:
        bucket: string
        expectedBucketOwner: string
        objectLockEnabled: string
        rule:
            defaultRetention:
                days: 0
                mode: string
                years: 0
        token: string
    

    BucketObjectLockConfigurationV2 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 BucketObjectLockConfigurationV2 resource accepts the following input properties:

    Bucket string
    Name of the bucket.
    ExpectedBucketOwner string
    Account ID of the expected bucket owner.
    ObjectLockEnabled string
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    Rule BucketObjectLockConfigurationV2Rule
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    Token string
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    Bucket string
    Name of the bucket.
    ExpectedBucketOwner string
    Account ID of the expected bucket owner.
    ObjectLockEnabled string
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    Rule BucketObjectLockConfigurationV2RuleArgs
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    Token string
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    bucket String
    Name of the bucket.
    expectedBucketOwner String
    Account ID of the expected bucket owner.
    objectLockEnabled String
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    rule BucketObjectLockConfigurationV2Rule
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    token String
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    bucket string
    Name of the bucket.
    expectedBucketOwner string
    Account ID of the expected bucket owner.
    objectLockEnabled string
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    rule BucketObjectLockConfigurationV2Rule
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    token string
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    bucket str
    Name of the bucket.
    expected_bucket_owner str
    Account ID of the expected bucket owner.
    object_lock_enabled str
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    rule BucketObjectLockConfigurationV2RuleArgs
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    token str
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    bucket String
    Name of the bucket.
    expectedBucketOwner String
    Account ID of the expected bucket owner.
    objectLockEnabled String
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    rule Property Map
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    token String
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the BucketObjectLockConfigurationV2 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 BucketObjectLockConfigurationV2 Resource

    Get an existing BucketObjectLockConfigurationV2 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?: BucketObjectLockConfigurationV2State, opts?: CustomResourceOptions): BucketObjectLockConfigurationV2
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            bucket: Optional[str] = None,
            expected_bucket_owner: Optional[str] = None,
            object_lock_enabled: Optional[str] = None,
            rule: Optional[BucketObjectLockConfigurationV2RuleArgs] = None,
            token: Optional[str] = None) -> BucketObjectLockConfigurationV2
    func GetBucketObjectLockConfigurationV2(ctx *Context, name string, id IDInput, state *BucketObjectLockConfigurationV2State, opts ...ResourceOption) (*BucketObjectLockConfigurationV2, error)
    public static BucketObjectLockConfigurationV2 Get(string name, Input<string> id, BucketObjectLockConfigurationV2State? state, CustomResourceOptions? opts = null)
    public static BucketObjectLockConfigurationV2 get(String name, Output<String> id, BucketObjectLockConfigurationV2State state, CustomResourceOptions options)
    resources:  _:    type: aws:s3:BucketObjectLockConfigurationV2    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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 string
    Name of the bucket.
    ExpectedBucketOwner string
    Account ID of the expected bucket owner.
    ObjectLockEnabled string
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    Rule BucketObjectLockConfigurationV2Rule
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    Token string
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    Bucket string
    Name of the bucket.
    ExpectedBucketOwner string
    Account ID of the expected bucket owner.
    ObjectLockEnabled string
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    Rule BucketObjectLockConfigurationV2RuleArgs
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    Token string
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    bucket String
    Name of the bucket.
    expectedBucketOwner String
    Account ID of the expected bucket owner.
    objectLockEnabled String
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    rule BucketObjectLockConfigurationV2Rule
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    token String
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    bucket string
    Name of the bucket.
    expectedBucketOwner string
    Account ID of the expected bucket owner.
    objectLockEnabled string
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    rule BucketObjectLockConfigurationV2Rule
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    token string
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    bucket str
    Name of the bucket.
    expected_bucket_owner str
    Account ID of the expected bucket owner.
    object_lock_enabled str
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    rule BucketObjectLockConfigurationV2RuleArgs
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    token str
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.
    bucket String
    Name of the bucket.
    expectedBucketOwner String
    Account ID of the expected bucket owner.
    objectLockEnabled String
    Indicates whether this bucket has an Object Lock configuration enabled. Defaults to Enabled. Valid values: Enabled.
    rule Property Map
    Configuration block for specifying the Object Lock rule for the specified object. See below.
    token String
    Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". The token is generated in the back-end when versioning is enabled on a bucket. For more details on versioning, see the aws.s3.BucketVersioningV2 resource.

    Supporting Types

    BucketObjectLockConfigurationV2Rule, BucketObjectLockConfigurationV2RuleArgs

    DefaultRetention BucketObjectLockConfigurationV2RuleDefaultRetention
    Configuration block for specifying the default Object Lock retention settings for new objects placed in the specified bucket. See below.
    DefaultRetention BucketObjectLockConfigurationV2RuleDefaultRetention
    Configuration block for specifying the default Object Lock retention settings for new objects placed in the specified bucket. See below.
    defaultRetention BucketObjectLockConfigurationV2RuleDefaultRetention
    Configuration block for specifying the default Object Lock retention settings for new objects placed in the specified bucket. See below.
    defaultRetention BucketObjectLockConfigurationV2RuleDefaultRetention
    Configuration block for specifying the default Object Lock retention settings for new objects placed in the specified bucket. See below.
    default_retention BucketObjectLockConfigurationV2RuleDefaultRetention
    Configuration block for specifying the default Object Lock retention settings for new objects placed in the specified bucket. See below.
    defaultRetention Property Map
    Configuration block for specifying the default Object Lock retention settings for new objects placed in the specified bucket. See below.

    BucketObjectLockConfigurationV2RuleDefaultRetention, BucketObjectLockConfigurationV2RuleDefaultRetentionArgs

    Days int
    Number of days that you want to specify for the default retention period.
    Mode string
    Default Object Lock retention mode you want to apply to new objects placed in the specified bucket. Valid values: COMPLIANCE, GOVERNANCE.
    Years int
    Number of years that you want to specify for the default retention period.
    Days int
    Number of days that you want to specify for the default retention period.
    Mode string
    Default Object Lock retention mode you want to apply to new objects placed in the specified bucket. Valid values: COMPLIANCE, GOVERNANCE.
    Years int
    Number of years that you want to specify for the default retention period.
    days Integer
    Number of days that you want to specify for the default retention period.
    mode String
    Default Object Lock retention mode you want to apply to new objects placed in the specified bucket. Valid values: COMPLIANCE, GOVERNANCE.
    years Integer
    Number of years that you want to specify for the default retention period.
    days number
    Number of days that you want to specify for the default retention period.
    mode string
    Default Object Lock retention mode you want to apply to new objects placed in the specified bucket. Valid values: COMPLIANCE, GOVERNANCE.
    years number
    Number of years that you want to specify for the default retention period.
    days int
    Number of days that you want to specify for the default retention period.
    mode str
    Default Object Lock retention mode you want to apply to new objects placed in the specified bucket. Valid values: COMPLIANCE, GOVERNANCE.
    years int
    Number of years that you want to specify for the default retention period.
    days Number
    Number of days that you want to specify for the default retention period.
    mode String
    Default Object Lock retention mode you want to apply to new objects placed in the specified bucket. Valid values: COMPLIANCE, GOVERNANCE.
    years Number
    Number of years that you want to specify for the default retention period.

    Import

    S3 bucket Object Lock configuration can be imported in one of two ways. If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, the S3 bucket Object Lock configuration resource should be imported using the bucket e.g.,

     $ pulumi import aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2 example bucket-name
    

    If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, the S3 bucket Object Lock configuration resource should be imported using the bucket and expected_bucket_owner separated by a comma (,) e.g.,

     $ pulumi import aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2 example bucket-name,123456789012
    

    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.
    aws logo
    Viewing docs for AWS v5.43.0 (Older version)
    published on Tuesday, Mar 10, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.