elithrar / pubsub-to-r2

An example Worker for copying Cloudflare Pub/Sub messages to R2 storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pubsub-to-r2

An example Cloudflare Worker that acts as an on-publish hook for Pub/Sub and copies a subset of messages to R2 object storage.

To deploy this to your own account:

  • Update account_id in wrangler.toml to use your own account ID
  • Update the [[r2_buckets]] configuration in wrangler.toml to reference an R2 bucket that exists in your account (see the R2 docs for more details)
  • Update the BROKER_PUBLIC_KEYS environmental variable with the public key set from your own Broker — the .../pubsub/namespaces/{namespace}/brokers/{broker}/publickeys endpoint in the API will return your broker-specific keys (docs)
  • Publish it with wrangler publish

With the Worker deployed, you can then update your Broker configuration to use the Worker as an on-publish hook by setting the on_publish.url field to the URL of your Worker (see the docs).

License

BSD-3-Clause licensed. Copyright Cloudflare, Inc, 2022.

About

An example Worker for copying Cloudflare Pub/Sub messages to R2 storage

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:TypeScript 100.0%