cloudflare / cloudflare/tf-migrate

`cloudflare_ruleset`: tf-migrate breaks cache rules with query string filters

Open
#324 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
33
Forks
12
Avg merge
1d 1h
Merged PRs (30d)
2

Description

### tf-migrate version

1.1.0

### Migration path

v4 to v5

### Affected resource type(s)

cloudflare_ruleset

### Description

According to https://github.com/cloudflare/terraform-provider-cloudflare/issues/6087 this conversion is plainly wrong and will break cache rules.

Note this quote: _Be aware that list = ["*"] does not mean "all parameters". In the new format, this would be interpreted as a rule that applies only to a query string parameter literally named *._

### Input configuration

```hcl
terraform {
required_version = ">= 1.5.0"
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.52"
}
}
}

provider "cloudflare" {
api_token = var.cloudflare_api_token
}

variable "cloudflare_api_token" {
type = string
sensitive = true
}

variable "zone_id" {
type = string
}

resource "cloudflare_ruleset" "cache_settings" {
zone_id = var.zone_id
name = "repro-cache-wildcard"
kind = "zone"
phase = "http_request_cache_settings"

rules {
action = "set_cache_settings"
expression = "http.host eq \"example.com\""
description = "repro"

action_parameters {
cache = true

cache_key {
custom_key {
query_string {
exclude = ["*"]
}
}
}
}

enabled = true
}
}
```

### Expected output

```hcl
(...)

exclude = { all = true }
```

### Actual output

```shell
(...)

exclude = {
list = ["*"]
}
```

### Steps to reproduce

Run tf-migrate on supplied code snippet.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the v4-to-v5 migration with the supplied cloudflare_ruleset HCL using tf-migrate 1.1.0, then trace the cloudflare_ruleset conversion that handles cache_key query_string filters. The fix is complete when exclude = ["*"] is migrated to exclude = { all = true }, with a regression test covering this input and output.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, terraform
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.