tf-migrate version
1.0.1
Migration path
v4 to v5
Affected resource type(s)
cloudflare_ruleset
Description
The tool converts a valid nested dynamic block into invalid syntax.
Input configuration
resource "cloudflare_ruleset" "http_ratelimit" {
account_id = cloudflare_account.abc.id
name = "Rate limit configuration"
description = "Apply rate limiting configuration"
kind = "custom"
phase = "http_ratelimit"
# All the rate limit rules using blocks instead of attribute lists
dynamic "rules" {
for_each = local.account_ratelimit_rules_with_ref
content {
action = try(rules.value.action, null)
description = try(rules.value.description, null)
enabled = try(rules.value.enabled, null)
expression = try(rules.value.expression, null)
ref = rules.value.ref
dynamic "ratelimit" {
for_each = [rules.value.ratelimit]
content {
characteristics = try(ratelimit.value.characteristics, null)
period = try(ratelimit.value.period, null)
requests_per_period = try(ratelimit.value.requests_per_period, null)
mitigation_timeout = try(ratelimit.value.mitigation_timeout, null)
counting_expression = try(ratelimit.value.counting_expression, null)
}
}
}
}
}
Expected output
resource "cloudflare_ruleset" "http_ratelimit" {
account_id = cloudflare_account.nlo.id
name = "Rate limit configuration"
description = "Apply rate limiting configuration"
kind = "custom"
phase = "http_ratelimit"
rules = [for rule in local.account_ratelimit_rules_with_ref : {
action = try(rule.action, null)
description = try(rule.description, null)
enabled = try(rule.enabled, null)
expression = try(rule.expression, null)
ref = rule.ref
ratelimit = {
characteristics = try(rule.ratelimit.characteristics, null)
counting_expression = try(rule.ratelimit.counting_expression, null)
mitigation_timeout = try(rule.ratelimit.mitigation_timeout, null)
period = try(rule.ratelimit.period, null)
requests_per_period = try(rule.ratelimit.requests_per_period, null)
}
}]
}
Actual output
Error: Reference to undeclared resource
│
│ on ../modules/cloudflare-account/rate_limit.tf line 66, in resource "cloudflare_ruleset" "http_ratelimit":
│ 66: characteristics = try(ratelimit.value.characteristics, null)
│
│ A managed resource "ratelimit" "value" has not been declared in module.account.
╵
╷
│ Error: Reference to undeclared resource
│
│ on ../modules/cloudflare-account/rate_limit.tf line 67, in resource "cloudflare_ruleset" "http_ratelimit":
│ 67: counting_expression = try(ratelimit.value.counting_expression, null)
│
│ A managed resource "ratelimit" "value" has not been declared in module.account.
╵
resource "cloudflare_ruleset" "http_ratelimit" {
account_id = cloudflare_account.abc.id
name = "Rate limit configuration"
description = "Apply rate limiting configuration"
kind = "custom"
phase = "http_ratelimit"
# All the rate limit rules using blocks instead of attribute lists
rules = [for rules in local.account_ratelimit_rules_with_ref : {
action = try(rules.action, null)
description = try(rules.description, null)
enabled = try(rules.enabled, null)
expression = try(rules.expression, null)
ref = rules.ref
dynamic = {
for_each = [rules.ratelimit]
content = {
characteristics = try(ratelimit.value.characteristics, null)
counting_expression = try(ratelimit.value.counting_expression, null)
mitigation_timeout = try(ratelimit.value.mitigation_timeout, null)
period = try(ratelimit.value.period, null)
requests_per_period = try(ratelimit.value.requests_per_period, null)
}
}
}
}
Steps to reproduce
No response
Additional context
No response
tf-migrate version
1.0.1
Migration path
v4 to v5
Affected resource type(s)
cloudflare_ruleset
Description
The tool converts a valid nested dynamic block into invalid syntax.
Input configuration
Expected output
Actual output
Steps to reproduce
No response
Additional context
No response