Hi,
I am trying to configure 2 bulk redirect lists using Terraform, but it fails with “failed to create ruleset “http_request_redirect” as a similar configuration with rules already exists and overwriting will have unintended consequences”. I have tried to remove both redirects before running TF, but it didn’t have any effect.
Here are the resources:
resource "cloudflare_ruleset" "en_redirects" {
account_id = local.account_id
name = "en_redirects"
kind = "root"
phase = "http_request_redirect"
rules {
action = "redirect"
action_parameters {
from_list {
name = cloudflare_list.en_redirects.name
key = "http.request.full_uri"
}
}
expression = "http.request.full_uri in $en_redirects"
description = "Apply redirects from en_redirects list"
enabled = true
}
}
resource "cloudflare_ruleset" "ru_to_ua_skill_redirects" {
account_id = local.account_id
name = "ru_to_ua_skill_redirects"
kind = "root"
phase = "http_request_redirect"
rules {
action = "redirect"
action_parameters {
from_list {
name = cloudflare_list.ru_skill_redirects.name
key = "http.request.full_uri"
}
}
expression = "http.request.full_uri in $ru_skill_redirects"
description = "Apply redirects from ru_skill_redirects list"
enabled = true
}
}
Running it results in:
Error: failed to create ruleset “http_request_redirect” 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 Documentation).
I went ahead and create the second redirect rule manually, and I think this helped to find a potential bug – although there are 2 bulk redirect lists created and I see both of the in UI, only “en_redirects” is returned from API. I think this is what breaks TF provider too.
curl "https://api.cloudflare.com/client/v4/accounts/YYY/rulesets" \
-H "Authorization: Bearer XXX"
{
"result": [
{
"id": "77454fe2d30c4220b5701f6fdfb893ba",
"name": "Cloudflare Managed Log4J Ruleset",
"description": "Created by the Cloudflare security team, this ruleset is designed to provide protection for free zones",
"source": "firewall_managed",
"kind": "managed",
"version": "50",
"last_updated": "2023-03-02T15:21:02.819432Z",
"phase": "http_request_firewall_managed"
},
{
"id": "4df688c7a877437284d35d6cb2b64427",
"name": "en_redirects",
"description": "",
"kind": "root",
"version": "4",
"last_updated": "2023-04-20T19:36:34.433476Z",
"phase": "http_request_redirect"
}
],
"success": true,
"errors": [],
"messages": []
}
Did anyone run into the same problem?