Repository: cloudflare/cloudflare-docs
Pull request #20566: Add R2 bucket lock changelog entry + update bucket lock docs
Author: login: jonesphillip
Labels: name: product:r2
description: R2 object storage: https://developers.cloudflare.com/r2
name: size/s
Created: 2025-03-05T22:13:05Z | Merged: 2025-03-06T18:02:20Z

Add R2 bucket lock changelog entry + update bucket lock docs


Diff:
diff --git a/src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx b/src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
new file mode 100644
index 000000000000000..6de77053611bd77
--- /dev/null
+++ b/src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
@@ -0,0 +1,33 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
+Locks give you a few ways to ensure your objects are retained (not deleted or overwritten). You can:
+
+- Lock objects for a specific duration, for example 90 days.
+- Lock objects until a certain date, for example January 1, 2030.
+- Lock objects indefinitely, until the lock is explicitly removed.
+
+Buckets can have up to 1,000 [bucket lock rules](/r2/buckets/). Each rule specifies which objects it covers (via prefix) and how long those objects must remain retained.
+
+Here are a couple of examples showing how you can configure bucket lock rules using [Wrangler](/workers/wrangler/):
+
+#### Ensure all objects in a bucket are retained for at least 180 days
+
+```sh
+npx wrangler r2 bucket lock add <bucket> --name 180-days-all --retention-days 180
+```
+
+#### Prevent deletion or overwriting of all logs indefinitely (via prefix)
+
+```sh
+npx wrangler r2 bucket lock add <bucket> --name indefinite-logs --prefix logs/ --retention-indefinite
+```
+
+For more information on bucket locks and how to set retention policies for objects in your R2 buckets, refer to our [documentation](/r2/buckets/bucket-locks/).
diff --git a/src/content/docs/r2/buckets/bucket-locks.mdx b/src/content/docs/r2/buckets/bucket-locks.mdx
index e14a9ce60f1ae5f..d4ca07e172a7c84 100644
--- a/src/content/docs/r2/buckets/bucket-locks.mdx
+++ b/src/content/docs/r2/buckets/bucket-locks.mdx
@@ -12,6 +12,14 @@ Before getting started, you will need:
 - An existing R2 bucket. If you do not already have an existing R2 bucket, refer to [Create buckets](/r2/buckets/create-buckets/).
 - (API only) An API token with [permissions](/r2/api/s3/tokens/#permissions) to edit R2 bucket configuration.
 
+### Enable bucket lock via dashboard
+
+1. From the Cloudflare dashboard, select **R2** from the sidebar.
+2. Select the bucket you would like to add bucket lock rule to.
+3. Switch to the **Settings** tab, then scroll down to the **Bucket lock rules** card.
+4. Select **Add rule** and enter the rule name, prefix, and retention period.
+5. Select **Save changes**.
+
 ### Enable bucket lock via Wrangler
 
 1. Install [`npm`](https://docs.npmjs.com/getting-started).
@@ -77,6 +85,12 @@ If your bucket is setup with [jurisdictional restrictions](/r2/reference/data-lo
 
 ## Get bucket lock rules for your R2 bucket
 
+### Dashboard
+
+1. From the Cloudflare dashboard, select **R2** from the sidebar.
+2. Select the bucket you would like to add bucket lock rule to.
+3. Switch to the **Settings** tab, then scroll down to the **Bucket lock rules** card.
+
 ### Wrangler
 
 To list bucket lock rules, run the [`r2 bucket lock list` command](/workers/wrangler/commands/#r2-bucket-lock-list):
@@ -91,6 +105,13 @@ For more information on required parameters and examples of how to get bucket lo
 
 ## Remove bucket lock rules from your R2 bucket
 
+### Dashboard
+
+1. From the Cloudflare dashboard, select **R2** from the sidebar.
+2. Select the bucket you would like to add bucket lock rule to.
+3. Switch to the **Settings** tab, then scroll down to the **Bucket lock rules** card.
+4. Locate the rule you want to remove, select the `...` icon next to it, and then select **Delete**.
+
 ### Wrangler
 
 To remove a bucket lock rule, run the [`r2 bucket lock remove` command](/workers/wrangler/commands/#r2-bucket-lock-remove):
diff --git a/src/content/partials/workers/wrangler-commands/r2.mdx b/src/content/partials/workers/wrangler-commands/r2.mdx
index d344f3959e3deee..c30b4a1a3653a85 100644
--- a/src/content/partials/workers/wrangler-commands/r2.mdx
+++ b/src/content/partials/workers/wrangler-commands/r2.mdx
@@ -263,8 +263,8 @@ wrangler r2 bucket lifecycle add <NAME> [OPTIONS]
 
 - `NAME` <Type text="string" /> <MetaInfo text="required" />
   - The name of the R2 bucket to add a lifecycle rule to.
-- `--id` <Type text="string" /> <MetaInfo text="optional" />
-  - A unique identifier for the lifecycle rule.
+- `--name` <Type text="string" /> <MetaInfo text="optional" />
+  - A unique name for the lifecycle rule, used to identify and manage it. For example: `delete-logs-180-days`.
 - `--prefix` <Type text="string" /> <MetaInfo text="optional" />
   - Prefix condition for the lifecycle rule (leave empty for all prefixes).
 - `--expire-days` <Type text="number" /> <MetaInfo text="optional" />
@@ -296,8 +296,8 @@ wrangler r2 bucket lifecycle remove <NAME> [OPTIONS]
 
 - `NAME` <Type text="string" /> <MetaInfo text="required" />
   - The name of the R2 bucket to remove a lifecycle rule from.
-- `--id` <Type text="string" /> <MetaInfo text="required" />
-  - The unique identifier of the lifecycle rule to remove.
+- `--name` <Type text="string" /> <MetaInfo text="required" />
+  - The unique name of the lifecycle rule to remove.
 - `--jurisdiction` <Type text="string" /> <MetaInfo text="optional" />
   - The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to [jurisdictional restrictions](/r2/reference/data-location/#jurisdictional-restrictions).
 
@@ -349,8 +349,8 @@ wrangler r2 bucket lock add <NAME> [OPTIONS]
 
 - `NAME` <Type text="string" /> <MetaInfo text="required" />
   - The name of the R2 bucket to add a bucket lock rule to.
-- `--id` <Type text="string" /> <MetaInfo text="optional" />
-  - A unique identifier for the bucket lock rule.
+- `--name` <Type text="string" /> <MetaInfo text="optional" />
+  - A unique name for the bucket lock rule, used to identify and manage it. For example: `retain-logs-180-days`.
 - `--prefix` <Type text="string" /> <MetaInfo text="optional" />
   - Prefix condition for the bucket lock rule (leave empty for all prefixes).
 - `--retention-days` <Type text="number" /> <MetaInfo text="optional" />
@@ -374,8 +374,8 @@ wrangler r2 bucket lock remove <NAME> [OPTIONS]
 
 - `NAME` <Type text="string" /> <MetaInfo text="required" />
   - The name of the R2 bucket to remove a bucket lock rule from.
-- `--id` <Type text="string" /> <MetaInfo text="required" />
-  - The unique identifier of the bucket lock rule to remove.
+- `--name` <Type text="string" /> <MetaInfo text="required" />
+  - The unique name of the bucket lock rule to remove.
 - `--jurisdiction` <Type text="string" /> <MetaInfo text="optional" />
   - The jurisdiction where the bucket exists, if a jurisdiction has been specified. Refer to [jurisdictional restrictions](/r2/reference/data-location/#jurisdictional-restrictions).
 


Reviews:
user: login: elithrar
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-05T22:19:51Z
user: login: elithrar
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-05T22:20:05Z
user: login: elithrar
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-05T22:20:16Z
user: login: elithrar
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-05T22:20:26Z
user: login: elithrar
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-05T22:24:47Z
user: login: jkoe-cf
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T23:01:02Z
user: login: jkoe-cf
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-05T23:11:24Z
user: login: elithrar
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-03-06T00:30:16Z
user: login: elithrar
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-06T00:31:35Z
user: login: Oxyjun
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T09:25:43Z
user: login: Oxyjun
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T09:25:59Z
user: login: Oxyjun
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T09:26:37Z
user: login: Oxyjun
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T09:26:52Z
user: login: Oxyjun
body: Some wording suggestions to clarify lock == retention
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T15:35:38Z
user: login: Oxyjun
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-06T15:38:12Z

Review comments:
diff_hunk: @@ -0,0 +1,23 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: elithrar
body: ```suggestion

Locks allow you to:

- Lock objects for a specific duration. For example, 90 days.
- Retain objects until a certain date. For example, until January 1, 2030.
- Keep objects locked indefinitely.
```
created_at: 2025-03-05T22:19:51Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,23 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
+Buckets can have up to 1,000 [bucket lock rules](/r2/buckets/). Each rule specifies which objects it covers (via prefix) and how long those objects must remain retained. You can:
+
+- Lock objects for a specific duration. For example, 90 days.
+- Retain objects until a certain date. For example, until January 1, 2030.
+- Keep objects locked indefinitely.
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: elithrar
body: ```suggestion
```
created_at: 2025-03-05T22:20:05Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,23 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
+Buckets can have up to 1,000 [bucket lock rules](/r2/buckets/). Each rule specifies which objects it covers (via prefix) and how long those objects must remain retained. You can:
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: elithrar
body: ```suggestion
Buckets can have up to 1,000 [bucket lock rules](/r2/buckets/). Each rule specifies which objects it covers (via prefix) and how long those objects must remain retained.
```
created_at: 2025-03-05T22:20:16Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,23 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: elithrar
body: contextualize what a lock is sooner
created_at: 2025-03-05T22:20:26Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,23 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
+Buckets can have up to 1,000 [bucket lock rules](/r2/buckets/). Each rule specifies which objects it covers (via prefix) and how long those objects must remain retained. You can:
+
+- Lock objects for a specific duration. For example, 90 days.
+- Retain objects until a certain date. For example, until January 1, 2030.
+- Keep objects locked indefinitely.
+
+Here's how you can add a bucket lock rule with [Wrangler](/workers/wrangler/):
+
+```sh
+npx wrangler r2 bucket lock add my-bucket
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: elithrar
body: ```suggestion
# Prevent deletion of objects in the bucket before 180 days
npx wrangler r2 bucket lock add <bucket> 180-days --retention-days=180

# Configure a rule for a subset of objects matching a prefix
npx wrangler r2 bucket lock add <bucket> indefinite-logs "logs" --retention-indefinite
```

Can we show a prefix or example rule file here?

Also - the API is a little weird. What is an ID? What is a valid ID? Why not generate it for the user?

```
‚ûú  npx wrangler r2 bucket lock add --help
wrangler r2 bucket lock add <bucket> [id] [prefix]

Add a lock rule to an R2 bucket

POSITIONALS
  bucket  The name of the R2 bucket to add a bucket lock rule to  [string] [required]
  id      A unique identifier for the bucket lock rule  [string]
  prefix  Prefix condition for the bucket lock rule (set to "" for all prefixes)  [string]
```
created_at: 2025-03-05T22:24:47Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,33 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
+Locks allow you to:
+
+- Lock objects for a specific duration. For example, 90 days.
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: jkoe-cf
body: consistency between lock object vs. retain object?
created_at: 2025-03-05T23:01:02Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,33 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
+Locks allow you to:
+
+- Lock objects for a specific duration. For example, 90 days.
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: elithrar
body: ```suggestion
- Lock objects for a specific duration: for example, preventing object deletion until 90 days.
```
created_at: 2025-03-06T00:31:35Z
author_association: COLLABORATOR
diff_hunk: @@ -12,6 +12,14 @@ Before getting started, you will need:
 - An existing R2 bucket. If you do not already have an existing R2 bucket, refer to [Create buckets](/r2/buckets/create-buckets/).
 - (API only) An API token with [permissions](/r2/api/s3/tokens/#permissions) to edit R2 bucket configuration.
 
+### Enable bucket lock via Dashboard
path: src/content/docs/r2/buckets/bucket-locks.mdx
user: login: Oxyjun
body: ```suggestion
### Enable bucket lock via dashboard
```
created_at: 2025-03-06T09:25:43Z
author_association: CONTRIBUTOR
diff_hunk: @@ -12,6 +12,14 @@ Before getting started, you will need:
 - An existing R2 bucket. If you do not already have an existing R2 bucket, refer to [Create buckets](/r2/buckets/create-buckets/).
 - (API only) An API token with [permissions](/r2/api/s3/tokens/#permissions) to edit R2 bucket configuration.
 
+### Enable bucket lock via Dashboard
+
+1. From the Cloudflare dashboard, select **R2** from the sidebar.
+2. Select the bucket you'd like to add bucket lock rule to.
path: src/content/docs/r2/buckets/bucket-locks.mdx
user: login: Oxyjun
body: ```suggestion
2. Select the bucket you would like to add bucket lock rule to.
```
created_at: 2025-03-06T09:25:59Z
author_association: CONTRIBUTOR
diff_hunk: @@ -77,6 +85,12 @@ If your bucket is setup with [jurisdictional restrictions](/r2/reference/data-lo
 
 ## Get bucket lock rules for your R2 bucket
 
+### Dashboard
+
+1. From the Cloudflare dashboard, select **R2** from the sidebar.
+2. Select the bucket you'd like to add bucket lock rule to.
path: src/content/docs/r2/buckets/bucket-locks.mdx
user: login: Oxyjun
body: ```suggestion
2. Select the bucket you would like to add bucket lock rule to.
```
created_at: 2025-03-06T09:26:37Z
author_association: CONTRIBUTOR
diff_hunk: @@ -91,6 +105,13 @@ For more information on required parameters and examples of how to get bucket lo
 
 ## Remove bucket lock rules from your R2 bucket
 
+### Dashboard
+
+1. From the Cloudflare dashboard, select **R2** from the sidebar.
+2. Select the bucket you'd like to add bucket lock rule to.
path: src/content/docs/r2/buckets/bucket-locks.mdx
user: login: Oxyjun
body: ```suggestion
2. Select the bucket you would like to add bucket lock rule to.
```
created_at: 2025-03-06T09:26:51Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,33 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
+Locks allow you to:
+
+- Lock objects for a specific duration. For example, 90 days.
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: Oxyjun
body: ```suggestion
- Lock objects against deletion for a specific duration, for example, for 90 days.
```
created_at: 2025-03-06T15:34:34Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,33 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
+Locks allow you to:
+
+- Lock objects for a specific duration. For example, 90 days.
+- Retain objects until a certain date. For example, until January 1, 2030.
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: Oxyjun
body: ```suggestion
- Lock objects against deletion until a specific date. For example, until January 1, 2030.
```
created_at: 2025-03-06T15:34:59Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,33 @@
+---
+title: Set retention polices for your R2 bucket with bucket locks
+description: Set retention polices for your R2 bucket with bucket locks
+products:
+  - r2
+date: 2025-03-06T10:00:00Z
+---
+
+You can now use [bucket locks](/r2/buckets/bucket-locks/) to set retention policies on your [R2 buckets](/r2/buckets/) (or specific prefixes within your buckets) for a specified period — or indefinitely. This can help ensure compliance by protecting important data from accidental or malicious deletion.
+
+Locks allow you to:
+
+- Lock objects for a specific duration. For example, 90 days.
+- Retain objects until a certain date. For example, until January 1, 2030.
+- Keep objects locked indefinitely.
path: src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx
user: login: Oxyjun
body: ```suggestion
- Lock objects against deletion indefinitely.
```
created_at: 2025-03-06T15:35:21Z
author_association: CONTRIBUTOR

PR comments:
user: login: github-actions[bot]
created_at: 2025-03-05T22:13:16Z
body: Howdy and thanks for contributing to our repo. We review internal PRs within **1 week**. If it's something urgent or has been sitting without a comment, start a thread in the *Developer Docs* space internally.
author_association: CONTRIBUTOR
user: login: github-actions[bot]
created_at: 2025-03-05T22:20:07Z
body: **Preview URL:** https://e59528ef.preview.developers.cloudflare.com
**Preview Branch URL:** https://pjones-bucket-lock-changelog.preview.developers.cloudflare.com

**Files with changes (up to 15)**

| Original Link | Updated Link |
| --- | --- |
| [https://developers.cloudflare.com/changelog/2025-03-06-r2-bucket-locks/](https://developers.cloudflare.com/changelog/2025-03-06-r2-bucket-locks/) | [https://pjones-bucket-lock-changelog.preview.developers.cloudflare.com/changelog/2025-03-06-r2-bucket-locks/](https://pjones-bucket-lock-changelog.preview.developers.cloudflare.com/changelog/2025-03-06-r2-bucket-locks/) |
| [https://developers.cloudflare.com/r2/buckets/bucket-locks/](https://developers.cloudflare.com/r2/buckets/bucket-locks/) | [https://pjones-bucket-lock-changelog.preview.developers.cloudflare.com/r2/buckets/bucket-locks/](https://pjones-bucket-lock-changelog.preview.developers.cloudflare.com/r2/buckets/bucket-locks/) |
author_association: CONTRIBUTOR