Hi everybody,
i’m trying to implement terraform on my cloudflare multiple zones (domain names) in order to create one security rule and apply it on my multiple zones (domain names). In order to implement this, i built a tf file with this
locals {
cloudflare_zones = {
myzone_com = {
zone_id = “XXX”
domain_name = “www.myzone.com”
}
myzone_org = {
zone_id = “XXX”
domain_name = “www.myzone.org”
}
}
}
resource "cloudflare_rate_limit" "default_rate_limit-hourly" {
for_each = local.cloudflare_zones
zone_id = each.value.zone_id
threshold = 2400
period = 3600
match {
request {
url_pattern = "${each.value.domain_name}/*"
schemes = ["_ALL_", ]
methods = ["_ALL_", ]
}
response {
statuses = []
origin_traffic = true
}
}
action {
mode = "simulate"
timeout = 3600
}
correlate {
by = "nat"
}
disabled = true
description = "Default rate limit - hourly"
}
It did not find other solutions than use locals to iterate on multiple associative tables like these ones. This is working fine.
In order to architect my project fine, i wanted to put these local vars in a dedicated variable file, but when i do that , i get this error
terraform plan -var-file var-cloudflare.tfvars
Error: Missing attribute separator
on var-cloudflare.tfvars line 1, in locals:
1: locals {
cloudflare_zones = {
myzone_com = {
zone_id = "XXX"
domain_name = "www.myzone.com"
}
myzone_org = {
zone_id = "XXX"
domain_name = "www.myzone.org"
}
}
}
Expected a newline or comma to mark the beginning of the next attribute.
Thanks very much for any help