I’d like to deploy my configuration via Terraform but I’m facing some issues when I deploy multiple cloudflare_rulesets.
I have now two rulesets of type http_response_headers_transform:
if I deploy the first one on its own, everything is ok
if I deploy the second one on its own, everything is ok
If I deploy both at the same time, the terraform apply fails with the following message
╷
│ Error: failed to create ruleset “http_response_headers_transform” as a similar configuration with rules already exists and overwriting will have unintended consequences. If you are migrating from the Dashboard, you will need to first remove the existing rules otherwise you can remove the existing phase yourself using the API (Cloudflare API v4 Documentation).
The message refers to existing rules, but those are the only ones available in this domain and none were created via the dashboard.
I’m wondering if your state has been messed up making terraform, thinking it needs to recreate the ruleset.
Can you try importing the ruleset? If that doesn’t work, then I would open a bug report on the terraform repo.
My state is correct as it only contains the “remove_common_IIS_headers” ruleset.
If I run a terraform plan, it correctly tells me it needs to create the “Disable_ACC_and_STA_indexing” ruleset and the terraform plan succeeds. It’s the terraform apply which then fails.
The fact that my state is correct should be confirmed by the fact that if I comment one of the ruleset, the uncommented gets applied and the other gets removed (if it was present).
Also, this is a brand new domain I am deploying exclusively via Terraform, so it’s really “clean”.