1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. R2BucketLock
Cloudflare v6.0.1 published on Wednesday, Apr 16, 2025 by Pulumi

cloudflare.R2BucketLock

Explore with Pulumi AI

Example Usage

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

const exampleR2BucketLock = new cloudflare.R2BucketLock("example_r2_bucket_lock", {
    accountId: "023e105f4ecef8ad9ca31a8372d0c353",
    bucketName: "example-bucket",
    rules: [{
        id: "Lock all objects for 24 hours",
        condition: {
            maxAgeSeconds: 100,
            type: "Age",
        },
        enabled: true,
        prefix: "prefix",
    }],
});
Copy
import pulumi
import pulumi_cloudflare as cloudflare

example_r2_bucket_lock = cloudflare.R2BucketLock("example_r2_bucket_lock",
    account_id="023e105f4ecef8ad9ca31a8372d0c353",
    bucket_name="example-bucket",
    rules=[{
        "id": "Lock all objects for 24 hours",
        "condition": {
            "max_age_seconds": 100,
            "type": "Age",
        },
        "enabled": True,
        "prefix": "prefix",
    }])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudflare.NewR2BucketLock(ctx, "example_r2_bucket_lock", &cloudflare.R2BucketLockArgs{
			AccountId:  pulumi.String("023e105f4ecef8ad9ca31a8372d0c353"),
			BucketName: pulumi.String("example-bucket"),
			Rules: cloudflare.R2BucketLockRuleArray{
				&cloudflare.R2BucketLockRuleArgs{
					Id: pulumi.String("Lock all objects for 24 hours"),
					Condition: &cloudflare.R2BucketLockRuleConditionArgs{
						MaxAgeSeconds: pulumi.Int(100),
						Type:          pulumi.String("Age"),
					},
					Enabled: pulumi.Bool(true),
					Prefix:  pulumi.String("prefix"),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;

return await Deployment.RunAsync(() => 
{
    var exampleR2BucketLock = new Cloudflare.R2BucketLock("example_r2_bucket_lock", new()
    {
        AccountId = "023e105f4ecef8ad9ca31a8372d0c353",
        BucketName = "example-bucket",
        Rules = new[]
        {
            new Cloudflare.Inputs.R2BucketLockRuleArgs
            {
                Id = "Lock all objects for 24 hours",
                Condition = new Cloudflare.Inputs.R2BucketLockRuleConditionArgs
                {
                    MaxAgeSeconds = 100,
                    Type = "Age",
                },
                Enabled = true,
                Prefix = "prefix",
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.cloudflare.R2BucketLock;
import com.pulumi.cloudflare.R2BucketLockArgs;
import com.pulumi.cloudflare.inputs.R2BucketLockRuleArgs;
import com.pulumi.cloudflare.inputs.R2BucketLockRuleConditionArgs;
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 exampleR2BucketLock = new R2BucketLock("exampleR2BucketLock", R2BucketLockArgs.builder()
            .accountId("023e105f4ecef8ad9ca31a8372d0c353")
            .bucketName("example-bucket")
            .rules(R2BucketLockRuleArgs.builder()
                .id("Lock all objects for 24 hours")
                .condition(R2BucketLockRuleConditionArgs.builder()
                    .maxAgeSeconds(100)
                    .type("Age")
                    .build())
                .enabled(true)
                .prefix("prefix")
                .build())
            .build());

    }
}
Copy
resources:
  exampleR2BucketLock:
    type: cloudflare:R2BucketLock
    name: example_r2_bucket_lock
    properties:
      accountId: 023e105f4ecef8ad9ca31a8372d0c353
      bucketName: example-bucket
      rules:
        - id: Lock all objects for 24 hours
          condition:
            maxAgeSeconds: 100
            type: Age
          enabled: true
          prefix: prefix
Copy

Create R2BucketLock Resource

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

Constructor syntax

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

@overload
def R2BucketLock(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 account_id: Optional[str] = None,
                 bucket_name: Optional[str] = None,
                 jurisdiction: Optional[str] = None,
                 rules: Optional[Sequence[R2BucketLockRuleArgs]] = None)
func NewR2BucketLock(ctx *Context, name string, args R2BucketLockArgs, opts ...ResourceOption) (*R2BucketLock, error)
public R2BucketLock(string name, R2BucketLockArgs args, CustomResourceOptions? opts = null)
public R2BucketLock(String name, R2BucketLockArgs args)
public R2BucketLock(String name, R2BucketLockArgs args, CustomResourceOptions options)
type: cloudflare:R2BucketLock
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. R2BucketLockArgs
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. R2BucketLockArgs
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. R2BucketLockArgs
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. R2BucketLockArgs
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. R2BucketLockArgs
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 r2bucketLockResource = new Cloudflare.R2BucketLock("r2bucketLockResource", new()
{
    AccountId = "string",
    BucketName = "string",
    Jurisdiction = "string",
    Rules = new[]
    {
        new Cloudflare.Inputs.R2BucketLockRuleArgs
        {
            Condition = new Cloudflare.Inputs.R2BucketLockRuleConditionArgs
            {
                Type = "string",
                Date = "string",
                MaxAgeSeconds = 0,
            },
            Enabled = false,
            Id = "string",
            Prefix = "string",
        },
    },
});
Copy
example, err := cloudflare.NewR2BucketLock(ctx, "r2bucketLockResource", &cloudflare.R2BucketLockArgs{
	AccountId:    pulumi.String("string"),
	BucketName:   pulumi.String("string"),
	Jurisdiction: pulumi.String("string"),
	Rules: cloudflare.R2BucketLockRuleArray{
		&cloudflare.R2BucketLockRuleArgs{
			Condition: &cloudflare.R2BucketLockRuleConditionArgs{
				Type:          pulumi.String("string"),
				Date:          pulumi.String("string"),
				MaxAgeSeconds: pulumi.Int(0),
			},
			Enabled: pulumi.Bool(false),
			Id:      pulumi.String("string"),
			Prefix:  pulumi.String("string"),
		},
	},
})
Copy
var r2bucketLockResource = new R2BucketLock("r2bucketLockResource", R2BucketLockArgs.builder()
    .accountId("string")
    .bucketName("string")
    .jurisdiction("string")
    .rules(R2BucketLockRuleArgs.builder()
        .condition(R2BucketLockRuleConditionArgs.builder()
            .type("string")
            .date("string")
            .maxAgeSeconds(0)
            .build())
        .enabled(false)
        .id("string")
        .prefix("string")
        .build())
    .build());
Copy
r2bucket_lock_resource = cloudflare.R2BucketLock("r2bucketLockResource",
    account_id="string",
    bucket_name="string",
    jurisdiction="string",
    rules=[{
        "condition": {
            "type": "string",
            "date": "string",
            "max_age_seconds": 0,
        },
        "enabled": False,
        "id": "string",
        "prefix": "string",
    }])
Copy
const r2bucketLockResource = new cloudflare.R2BucketLock("r2bucketLockResource", {
    accountId: "string",
    bucketName: "string",
    jurisdiction: "string",
    rules: [{
        condition: {
            type: "string",
            date: "string",
            maxAgeSeconds: 0,
        },
        enabled: false,
        id: "string",
        prefix: "string",
    }],
});
Copy
type: cloudflare:R2BucketLock
properties:
    accountId: string
    bucketName: string
    jurisdiction: string
    rules:
        - condition:
            date: string
            maxAgeSeconds: 0
            type: string
          enabled: false
          id: string
          prefix: string
Copy

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

AccountId This property is required. string
Account ID
BucketName This property is required. string
Name of the bucket
Jurisdiction string
Jurisdiction of the bucket
Rules List<R2BucketLockRule>
AccountId This property is required. string
Account ID
BucketName This property is required. string
Name of the bucket
Jurisdiction string
Jurisdiction of the bucket
Rules []R2BucketLockRuleArgs
accountId This property is required. String
Account ID
bucketName This property is required. String
Name of the bucket
jurisdiction String
Jurisdiction of the bucket
rules List<R2BucketLockRule>
accountId This property is required. string
Account ID
bucketName This property is required. string
Name of the bucket
jurisdiction string
Jurisdiction of the bucket
rules R2BucketLockRule[]
account_id This property is required. str
Account ID
bucket_name This property is required. str
Name of the bucket
jurisdiction str
Jurisdiction of the bucket
rules Sequence[R2BucketLockRuleArgs]
accountId This property is required. String
Account ID
bucketName This property is required. String
Name of the bucket
jurisdiction String
Jurisdiction of the bucket
rules List<Property Map>

Outputs

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

Get an existing R2BucketLock 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?: R2BucketLockState, opts?: CustomResourceOptions): R2BucketLock
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        account_id: Optional[str] = None,
        bucket_name: Optional[str] = None,
        jurisdiction: Optional[str] = None,
        rules: Optional[Sequence[R2BucketLockRuleArgs]] = None) -> R2BucketLock
func GetR2BucketLock(ctx *Context, name string, id IDInput, state *R2BucketLockState, opts ...ResourceOption) (*R2BucketLock, error)
public static R2BucketLock Get(string name, Input<string> id, R2BucketLockState? state, CustomResourceOptions? opts = null)
public static R2BucketLock get(String name, Output<String> id, R2BucketLockState state, CustomResourceOptions options)
resources:  _:    type: cloudflare:R2BucketLock    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:
AccountId string
Account ID
BucketName string
Name of the bucket
Jurisdiction string
Jurisdiction of the bucket
Rules List<R2BucketLockRule>
AccountId string
Account ID
BucketName string
Name of the bucket
Jurisdiction string
Jurisdiction of the bucket
Rules []R2BucketLockRuleArgs
accountId String
Account ID
bucketName String
Name of the bucket
jurisdiction String
Jurisdiction of the bucket
rules List<R2BucketLockRule>
accountId string
Account ID
bucketName string
Name of the bucket
jurisdiction string
Jurisdiction of the bucket
rules R2BucketLockRule[]
account_id str
Account ID
bucket_name str
Name of the bucket
jurisdiction str
Jurisdiction of the bucket
rules Sequence[R2BucketLockRuleArgs]
accountId String
Account ID
bucketName String
Name of the bucket
jurisdiction String
Jurisdiction of the bucket
rules List<Property Map>

Supporting Types

R2BucketLockRule
, R2BucketLockRuleArgs

Condition This property is required. R2BucketLockRuleCondition
Condition to apply a lock rule to an object for how long in seconds
Enabled This property is required. bool
Whether or not this rule is in effect
Id This property is required. string
Unique identifier for this rule
Prefix string
Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads
Condition This property is required. R2BucketLockRuleCondition
Condition to apply a lock rule to an object for how long in seconds
Enabled This property is required. bool
Whether or not this rule is in effect
Id This property is required. string
Unique identifier for this rule
Prefix string
Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads
condition This property is required. R2BucketLockRuleCondition
Condition to apply a lock rule to an object for how long in seconds
enabled This property is required. Boolean
Whether or not this rule is in effect
id This property is required. String
Unique identifier for this rule
prefix String
Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads
condition This property is required. R2BucketLockRuleCondition
Condition to apply a lock rule to an object for how long in seconds
enabled This property is required. boolean
Whether or not this rule is in effect
id This property is required. string
Unique identifier for this rule
prefix string
Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads
condition This property is required. R2BucketLockRuleCondition
Condition to apply a lock rule to an object for how long in seconds
enabled This property is required. bool
Whether or not this rule is in effect
id This property is required. str
Unique identifier for this rule
prefix str
Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads
condition This property is required. Property Map
Condition to apply a lock rule to an object for how long in seconds
enabled This property is required. Boolean
Whether or not this rule is in effect
id This property is required. String
Unique identifier for this rule
prefix String
Rule will only apply to objects/uploads in the bucket that start with the given prefix, an empty prefix can be provided to scope rule to all objects/uploads

R2BucketLockRuleCondition
, R2BucketLockRuleConditionArgs

Type This property is required. string
Available values: "Age".
Date string
MaxAgeSeconds int
Type This property is required. string
Available values: "Age".
Date string
MaxAgeSeconds int
type This property is required. String
Available values: "Age".
date String
maxAgeSeconds Integer
type This property is required. string
Available values: "Age".
date string
maxAgeSeconds number
type This property is required. str
Available values: "Age".
date str
max_age_seconds int
type This property is required. String
Available values: "Age".
date String
maxAgeSeconds Number

Package Details

Repository
Cloudflare pulumi/pulumi-cloudflare
License
Apache-2.0
Notes
This Pulumi package is based on the cloudflare Terraform Provider.