Cloudflare Terraform Provider
Find a file
stainless-app[bot] a427943937
Some checks are pending
Acceptance Tests / Workers Extended Tests (push) Waiting to run
Acceptance Tests / Workers Platform Tests (push) Waiting to run
Acceptance Tests / Access Applications Tests (push) Waiting to run
Acceptance Tests / Web Features Tests (push) Waiting to run
Acceptance Tests / Web Monitoring Tests (push) Waiting to run
Acceptance Tests / Workers Core Tests (push) Waiting to run
Acceptance Tests / Access Core Tests (push) Waiting to run
Acceptance Tests / Access Identity Tests (push) Waiting to run
Acceptance Tests / Access mTLS Tests (push) Waiting to run
Acceptance Tests / DLP Config Tests (push) Waiting to run
Acceptance Tests / Gateway and Policies Tests (push) Waiting to run
Acceptance Tests / Zero Trust List Tests (push) Waiting to run
Acceptance Tests / Zero Trust Organization Tests (push) Waiting to run
Acceptance Tests / Zone Core Tests (push) Waiting to run
Acceptance Tests / Zone Settings Tests (push) Waiting to run
Acceptance Tests / Check Test Results (push) Blocked by required conditions
Acceptance Tests / Organization Tests (push) Waiting to run
Acceptance Tests / Account Core Tests (push) Waiting to run
Acceptance Tests / Account Settings Tests (push) Waiting to run
Acceptance Tests / CDN Advanced Tests (push) Waiting to run
Acceptance Tests / Default Tests (push) Waiting to run
Acceptance Tests / DNS Tests (push) Waiting to run
Acceptance Tests / Email Routing Tests (push) Waiting to run
Acceptance Tests / Email Security Tests (push) Waiting to run
Acceptance Tests / General API Tests (push) Waiting to run
Acceptance Tests / Load Balancing Tests (push) Waiting to run
Acceptance Tests / Magic Tests (push) Waiting to run
Acceptance Tests / Queue and Messaging Tests (push) Waiting to run
Acceptance Tests / Misc Account Tools Tests (push) Waiting to run
Acceptance Tests / Pages Tests (push) Waiting to run
Acceptance Tests / Performance Tests (push) Waiting to run
Acceptance Tests / Platform and Advanced Tests (push) Waiting to run
Acceptance Tests / Rules and Policies Tests (push) Waiting to run
Acceptance Tests / Security Advanced Tests (push) Waiting to run
Acceptance Tests / Security Core Tests (push) Waiting to run
Acceptance Tests / Snippets Tests (push) Waiting to run
Acceptance Tests / SSL Config Tests (push) Waiting to run
Acceptance Tests / R2 Storage Tests (push) Waiting to run
Acceptance Tests / TLS and Certificates Tests (push) Waiting to run
Acceptance Tests / Tunnel Cloudflared Tests (push) Waiting to run
Acceptance Tests / Tunnel Devices Tests (push) Waiting to run
Acceptance Tests / Waiting Room Tests (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
release: 5.16.0
2026-01-16 16:35:14 +00:00
.claude prompt improvements 2025-08-14 17:23:55 -07:00
.github chore: remove stalebot 2026-01-07 12:15:34 -05:00
.grit release: 5.13.0 (#6397) 2025-11-21 01:26:53 -08:00
bin fix(ci): release-doctor — report correct token name 2025-07-07 22:49:16 +00:00
cmd/migrate release: 5.13.0 (#6397) 2025-11-21 01:26:53 -08:00
contributing release: 5.13.0 (#6397) 2025-11-21 01:26:53 -08:00
docs docs(api_shield): add jwt session identifier documentation 2026-01-13 21:46:53 +00:00
examples chore(api): update composite API spec 2026-01-15 22:22:50 +00:00
internal release: 5.16.0 2026-01-16 16:35:14 +00:00
scripts feat(worker_route): use v2 migrator: 2025-12-29 10:56:50 +01:00
templates docs(api_shield): add jwt session identifier documentation 2026-01-13 21:46:53 +00:00
tools feat: various codegen changes 2025-02-13 02:17:17 +00:00
.gitignore chore: update to v5 2025-08-05 09:48:01 -07:00
.golangci.yml release: 5.14.0 (#6481) 2025-12-05 16:57:14 -08:00
.goreleaser.yml release: 5.10.0 (#6073) 2025-09-12 15:57:59 -07:00
.release-please-manifest.json release: 5.16.0 2026-01-16 16:35:14 +00:00
.stats.yml feat(api): manual updates 2026-01-16 03:48:30 +00:00
Brewfile feat(api): api update (#4480) 2024-10-30 19:12:50 +00:00
CHANGELOG.md release: 5.16.0 2026-01-16 16:35:14 +00:00
CONTRIBUTING.md feat: various codegen changes 2025-02-13 02:17:17 +00:00
go.mod feat(api): manual updates 2026-01-16 03:48:30 +00:00
go.sum feat(api): manual updates 2026-01-16 03:48:30 +00:00
LICENSE chore(api): update composite API spec 2026-01-04 22:10:07 +00:00
main.go chore: add README (#4053) 2024-09-18 18:06:48 +00:00
README.md release: 5.16.0 2026-01-16 16:35:14 +00:00
release-please-config.json fix(release): update README and version correctly in release PRs 2025-05-14 13:54:35 +00:00
RELEASING.md Update RELEASING.md 2025-05-06 15:11:44 +10:00
SECURITY.md chore(docs): grammar improvements 2025-05-21 21:23:52 +00:00
terraform-registry-manifest.json fix file permissions 2024-09-06 13:03:12 -04:00

Cloudflare Terraform Provider

The Cloudflare Terraform provider provides convenient access to the Cloudflare REST API from Terraform.

Requirements

This provider requires Terraform CLI 1.0 or later. You can install it for your system on Hashicorp's website.

Usage

Add the following to your main.tf file:

# Declare the provider and version
terraform {
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "~> 5.16.0"
    }
  }
}

# Initialize the provider
provider "cloudflare" {
  # The preferred authorization scheme for interacting with the Cloudflare API. [Create a token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/).
  api_token = "Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY" # or set CLOUDFLARE_API_TOKEN env variable
  # The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
  api_key = "144c9defac04969c7bfad8efaa8ea194" # or set CLOUDFLARE_API_KEY env variable
  # The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
  api_email = "user@example.com" # or set CLOUDFLARE_EMAIL env variable
  # Used when interacting with the Origin CA certificates API. [View/change your key](https://developers.cloudflare.com/fundamentals/api/get-started/ca-keys/#viewchange-your-origin-ca-keys).
  user_service_key = "v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719" # or set CLOUDFLARE_API_USER_SERVICE_KEY env variable
}

# Configure a resource
resource "cloudflare_zone" "example_zone" {
  account = {
    id = "023e105f4ecef8ad9ca31a8372d0c353"
  }
  name = "example.com"
  type = "full"
}

Initialize your project by running terraform init in the directory.

Additional examples can be found in the ./examples folder within this repository, and you can refer to the full documentation on the Terraform Registry.

Provider Options

When you initialize the provider, the following options are supported. It is recommended to use environment variables for sensitive values like access tokens. If an environment variable is provided, then the option does not need to be set in the terraform source.

Property Environment variable Required Default value
user_service_key CLOUDFLARE_API_USER_SERVICE_KEY false
api_token CLOUDFLARE_API_TOKEN false
api_key CLOUDFLARE_API_KEY false
api_email CLOUDFLARE_EMAIL false

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Maintenance

This SDK is actively maintained, however, many issues are tracked outside of GitHub on internal Cloudflare systems. Members of the community are welcome to join and discuss your issues during our weekly triage meetings. For urgent issues, please contact Cloudflare support.

Contributing

See the contributing documentation.