Skip to content

Commit 8fc464c

Browse files
committed
pr suggestion: Added example lock rules per
1 parent 3990ec1 commit 8fc464c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/content/changelog/r2/2025-03-06-r2-bucket-locks.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@ Locks allow you to:
1313
- Lock objects for a specific duration. For example, 90 days.
1414
- Retain objects until a certain date. For example, until January 1, 2030.
1515
- Keep objects locked indefinitely.
16+
1617
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.
1718

19+
Here are a couple of examples showing how you can configure bucket lock rules using [Wrangler](/workers/wrangler/):
20+
21+
#### Ensure all objects in a bucket are retained for at least 180 days
22+
23+
```sh
24+
npx wrangler r2 bucket lock add <bucket> --id 180-days-all --retention-days 180
25+
```
1826

19-
Here's how you can add a bucket lock rule with [Wrangler](/workers/wrangler/):
27+
#### Prevent deletion or overwriting of all logs indefinitely (via prefix)
2028

2129
```sh
22-
npx wrangler r2 bucket lock add my-bucket
30+
npx wrangler r2 bucket lock add <bucket> --id indefinite-logs --prefix logs/ --retention-indefinite
2331
```
2432

2533
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/).

src/content/partials/workers/wrangler-commands/r2.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ wrangler r2 bucket lifecycle add <NAME> [OPTIONS]
264264
- `NAME` <Type text="string" /> <MetaInfo text="required" />
265265
- The name of the R2 bucket to add a lifecycle rule to.
266266
- `--id` <Type text="string" /> <MetaInfo text="optional" />
267-
- A unique identifier for the lifecycle rule.
267+
- A unique name for the lifecycle rule, used to identify and manage it.
268268
- `--prefix` <Type text="string" /> <MetaInfo text="optional" />
269269
- Prefix condition for the lifecycle rule (leave empty for all prefixes).
270270
- `--expire-days` <Type text="number" /> <MetaInfo text="optional" />
@@ -350,7 +350,7 @@ wrangler r2 bucket lock add <NAME> [OPTIONS]
350350
- `NAME` <Type text="string" /> <MetaInfo text="required" />
351351
- The name of the R2 bucket to add a bucket lock rule to.
352352
- `--id` <Type text="string" /> <MetaInfo text="optional" />
353-
- A unique identifier for the bucket lock rule.
353+
- A unique name for the bucket lock rule, used to identify and manage it.
354354
- `--prefix` <Type text="string" /> <MetaInfo text="optional" />
355355
- Prefix condition for the bucket lock rule (leave empty for all prefixes).
356356
- `--retention-days` <Type text="number" /> <MetaInfo text="optional" />

0 commit comments

Comments
 (0)