Skip to content

Feature Request: Support cloudflare_secrets_store and cloudflare_secrets_store_secret resource types #6939

@trafgals

Description

@trafgals

Summary

The Cloudflare Terraform provider should support cloudflare_secrets_store and cloudflare_secrets_store_secret resource types to allow managing Secrets Store resources via Terraform, similar to how cloudflare_workers_secret worked before it was removed in v5.

Use Case

Managing worker secrets via Terraform for CI/CD pipelines. Currently, teams must use the Workers Secrets API directly (via wrangler or curl) or use secret_text bindings on cloudflare_workers_script, but this doesn't provide a centralized secrets management approach.

Example Configuration (Currently Not Working)

resource "cloudflare_secrets_store" "worker" {
  name = "my-app-secrets-\${terraform.workspace}"
}

resource "cloudflare_secrets_store_secret" "api_key" {
  store_id    = cloudflare_secrets_store.worker.id
  secret_name = "API_KEY"
  secret_text = var.api_key
}

This results in error: The provider cloudflare/cloudflare does not support resource type "cloudflare_secrets_store".

Expected Behavior

Terraform should be able to:

  1. Create a Secrets Store (POST /accounts/{account_id}/secrets_stores)
  2. Add secrets to the store (PUT /accounts/{account_id}/secrets_stores/{name}/secrets/{secret_name})
  3. Support bindings via cloudflare_workers_script resource with secrets_store_secret binding type

References

Alternative Approaches Considered

  1. Using wrangler secret put - Works but requires CI pipeline changes to call wrangler instead of using Terraform
  2. Using secret_text bindings - Works but doesn't provide centralized secret management
  3. Using Workers Secrets API directly - Works but requires custom scripting

The Terraform-native approach would be preferred for teams using Terraform as their IaC tool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementCategorizes issue or PR as related to improving an existing feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions