Skip to main content

Cloudflare Workers KV

Type: state.cloudflare.workerskv

Status: beta

Reference: https://docs.dapr.io/reference/components-reference/supported-state-stores/setup-cloudflare-workerskv/

Example

apiVersion: cra.diagrid.io/v1beta1
kind: Component
metadata:
name: <name>
spec:
type: state.cloudflare.workerskv
version: v1
metadata:
# API token for Cloudflare. Required to have Dapr manage the Worker.
- name: cfAPIToken
value: "secret-key"
# Cloudflare account ID. Required to have Dapr manage the worker.
- name: cfAccountID
value: "456789abcdef8b5588f3d134f74ac"
# Key for authenticating calls from Dapr to the Worker. This is an Ed25519 private key, PEM-encoded.
- name: key
value: |
-----BEGIN PRIVATE KEY-----
MC4CAQ...
-----END PRIVATE KEY-----

# ID of the pre-created Workers KV namespace.
- name: kvNamespaceID
value: "123456789abcdef8b5588f3d134f74ac"
# Name of the Worker to connect to.
- name: workerName
value: "mydaprkv"
# Prefix added to keys in the state store. (Optional)
#- name: keyPrefix
# value: "appid"
# Timeout for network requests, in seconds. (Optional)
#- name: timeoutInSeconds
# value: "20"

Authentication profiles

Available authentication profiles:

  • Cloudflare API Token

  • No authentication

Cloudflare API Token

Authenticate with a Cloudflare API token to let Dapr manage your Worker

cfAPIToken

Required - API token for Cloudflare. Required to have Dapr manage the Worker.

Example value: secret-key

cfAccountID

Required - Cloudflare account ID. Required to have Dapr manage the worker.

Example value: 456789abcdef8b5588f3d134f74ac

No authentication

Using a pre-previsioned Worker that is not managed by Dapr doesn't require authenticating with Cloudflare

workerUrl (string)

Required - URL of the pre-provisioned Worker

Example value: https://mydaprkv.mydomain.workers.dev

Metadata

key

Required - Key for authenticating calls from Dapr to the Worker. This is an Ed25519 private key, PEM-encoded.

Example value:

-----BEGIN PRIVATE KEY-----
MC4CAQ...
-----END PRIVATE KEY-----

kvNamespaceID (string)

Required - ID of the pre-created Workers KV namespace.

Example value: 123456789abcdef8b5588f3d134f74ac

workerName (string)

Required - Name of the Worker to connect to.

Example value: mydaprkv

keyPrefix (string)

Prefix added to keys in the state store.

Default value: appid

Example value: appid

Allowed values:

  • appid

  • name

  • none

Documentation: https://docs.dapr.io/developing-applications/building-blocks/state-management/howto-share-state/

timeoutInSeconds (number)

Timeout for network requests, in seconds.

Default value: 20

Example value: 20