Skip to content
/ r2-ttl-worker Public template

A Clouflare Worker that remove expired objects based on a TTL of 30 days

Notifications You must be signed in to change notification settings

Blad3Mak3r/r2-ttl-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

R2 TTL WORKER

Use this template to create a Cloudflare Worker that will allow you to automatically delete objects older than 30 days in a R2 Bucket.

Getting started

  1. Install wrangler using npm npm i -g wrangler@latest.
  2. Login with your Cloudflare account using wrangler login
  3. Create an .env file following the guide in the Cloudflare Workers documentation (env file will not be commited).
  4. Get the name of the bucket you want to use with the wrangler r2 bucket list command.
  5. Edit your wrangler.toml file and change YOUR BUCKET NAME with the name of the bucket you want to bind.
  6. Run wrangler publish and the worker will be created.

Changing the Worker name

You can change the name of the Worker simply by changing the name= variable in your wrangler.toml file

Changing cron scheduled time

Just go to wrangler.toml and replace crons = [ "0 8 * * *" ] with your needed crons (crons tutorial)

About

A Clouflare Worker that remove expired objects based on a TTL of 30 days

Topics

Resources

Stars

Watchers

Forks