Questions tagged [terraform-provider-cloudflare]

21 questions
158
votes
4 answers

Terraform: Conditional creation of a resource based on a variable in .tfvars

I have resources defined in .tf files that are generic to several applications. I populate many of the fields via a .tfvars file. I need to omit some of the resources entirely based on variables in the .tfvars. For example if I have a resource…
Joel Guerra
  • 4,760
  • 4
  • 12
  • 26
2
votes
3 answers

Cloudflare page rules using terraform-cloudflare provider does not update page rules

I am using Terraform + Cloudflare provider. I created a page rule the fist time I ran terraform plan + terraform apply. Running the same command a second time returns the error: Error: Failed to create page rule: error from makeRequest: HTTP status…
2
votes
3 answers

Apply cloudflare_zone_settings_override to multiple zones

I am just getting my feet wet with Terraform but I don't see an obvious way to keep me from repeating myself. I have a bunch of zones in Cloudlfare that I want to manage. These zones will all have very similar settings and I want my .tf files to be…
ScruffyDan
  • 23
  • 2
2
votes
1 answer

Routing requests using cloudflare to different web applications

I currently have two web apps that are set up in cloudflare with the following CNAMEs. Both are keystonejs applications. app1.example.com ===pointing to ===> AWS ALB 1 app2.example.com ===pointing to ===> AWS ALB 2 I have Cloudflare Enterprise set…
1
vote
1 answer

Get data from terraform Output and use it as input

I'm using Terraform to build and automate infrastructure and I'm having trouble in finding the solution to grab the output of an Azure WebApp, specifically the Public IP addresses used by that WebApp and use them as inputs to update a Cloudflare…
1
vote
2 answers

Create a Cloudflare Geo WAF Country block with Terraform

I am trying to write a terraform script to apply a country block in Cloudflare for one of my websites. However, I am not entirely sure if I'm doing it right. For context this is using the Free Cloudflare plan. My terraform script is below: resource…
Ben Taylor
  • 81
  • 1
  • 4
1
vote
1 answer

How to Create Cloudflare Origin CA certificate via API without providing private key and CSR

Via the Cloudflare UI (see image), it's possible to create an Origin CA certificate without providing a private key and CSR. Cloudflare will generate this for you. I've tried to find the corresponding approach using the Cloudflare API, but it seems…
Joel
  • 8,502
  • 11
  • 66
  • 115
1
vote
0 answers

Permission denied to create zone

I get this message after terraform apply: Error: Error creating zone "example.com": HTTP status 400: Permission denied (1068) Here's the content of both provider.tf and zone.tf terraform { required_providers { cloudflare = { source =…
bulkmoustache
  • 1,875
  • 3
  • 20
  • 24
1
vote
2 answers

Default DNS records in every zone managed via terraform (eg. MX records)

I'm looking for a way to manage cloudflare zones and records with terraform and create some default records (eg. MX) in every zone that is managed via terraform, something like this: resource "cloudflare_zone" "example_net" { type = "full" …
DerDomme
  • 11
  • 1
1
vote
0 answers

How to disable Cloudflare Browser Insights via API or Terraform?

I can not find any information about Cloudflare Browser Insights on the API documentation. https://support.cloudflare.com/hc/en-us/articles/360033929991-Cloudflare-Browser-Insights#5tDRl4LGok5jnHLGwuSww5 How can I disable it programatically?
Alex Benfica
  • 408
  • 5
  • 17
1
vote
2 answers

Creation a always_use_https pagerule failed with error Invalid setting always_use_https

Here is my rule resource "cloudflare_page_rule" "https-only" { zone = "${var.domain}" target = "http://*${var.domain}/*" priority = 1 actions = { always_use_https = true, } } The documentation says the default value of…
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
1
vote
0 answers

Cannot contain self-reference in terraform cloudflare page rule

I want to create a pagerule to ensure all the incoming http traffic will be converted to https Here is my rule: resource "cloudflare_page_rule" "https-only" { zone = "${var.domain}" domain = "${var.domain}" target =…
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
0
votes
1 answer

Terraform v1.5.4 dynamic items failing on coalesce options

I'm new to Terraform. I'm tying to utilize a local yaml file as data source for a dynamic list for a slew of redirects in Cloudflare. I can get it to work by not using the coalesce default option and having every entry in the yaml file include a…
0
votes
1 answer

cloudflare_worker_script multiple files

Using CloudFlare web dashboard it's possible to split your code into multiple files using ES module syntax. It works out of the box. Is it possible to create such configuration using CF Terraform provider and cloudflare_worker_script without JS…
0
votes
1 answer

terraform plan resource cloudflare_list always wants to update in-place without changes

I've used terraform code like the example below to successfully create a list of IP addresses: resource "cloudflare_list" "example" { account_id = "f037e56e89293a057740de681ac9abbe" name = "example_list" description = "example IPs for…
Nagev
  • 10,835
  • 4
  • 58
  • 69
1
2