The Cloudflare provider is used to interact with resources supported by Cloudflare. The provider needs to be configured with the proper credentials before it can be used.
Try the getting started tutorial on developers.cloudflare.com. In the walk through, you will setup Terraform and learn to manage Cloudflare resources such as DNS records, zone settings, load balancers and much more!
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 5"
}
}
}
provider "cloudflare" {
api_token = var.cloudflare_api_token
}
# Create a DNS record
resource "cloudflare_dns_record" "www" {
# ...
}
api_key
(String) The API key for operations. Alternatively, can be configured using the CLOUDFLARE_API_KEY
environment variable. API keys are now considered legacy by Cloudflare, API tokens should be used instead. Must provide only one of api_key
, api_token
, api_user_service_key
.api_token
(String) The API Token for operations. Alternatively, can be configured using the CLOUDFLARE_API_TOKEN
environment variable. Must provide only one of api_key
, api_token
, api_user_service_key
.api_user_service_key
(String) A special Cloudflare API key good for a restricted set of endpoints. Alternatively, can be configured using the CLOUDFLARE_API_USER_SERVICE_KEY
environment variable. Must provide only one of api_key
, api_token
, api_user_service_key
.base_url
(String) Value to override the default HTTP client base URL. Alternatively, can be configured using the base_url
environment variable.email
(String) A registered Cloudflare email address. Alternatively, can be configured using the CLOUDFLARE_EMAIL
environment variable. Required when using api_key
. Conflicts with api_token
.user_agent_operator_suffix
(String) A value to append to the HTTP User Agent for all API calls. This value is not something most users need to modify however, if you are using a non-standard provider or operator configuration, this is recommended to assist in uniquely identifying your traffic. Setting this value will remove the Terraform version from the HTTP User Agent string and may have unintended consequences. Alternatively, can be configured using the CLOUDFLARE_USER_AGENT_OPERATOR_SUFFIX
environment variable.