Secrets Store
Read account-level secrets from the Cloudflare Secrets Store.
The Secrets Store holds account-level secrets that can be bound to a worker. The exp/cloudflare/secretsstore package wraps the SecretsStoreSecret binding.
Declare the binding
Each [[secrets_store_secrets]] entry maps one secret — identified by store_id and secret_name — to a binding name.
[[secrets_store_secrets]]
binding = "MY_SECRET"
store_id = "<your store id>"
secret_name = "<your secret name>"
Read a secret
secretsstore.NewSecretsStoreSecret resolves the binding by name. Get returns the secret value as a string, or an error if the secret does not exist.
import "github.com/syumai/workers-go/exp/cloudflare/secretsstore"
secret, err := secretsstore.NewSecretsStoreSecret("MY_SECRET")
if err != nil {
return err
}
value, err := secret.Get()
if err != nil {
return err
}