I am just getting my feet wet with Terraform but I don't see an obvious way to keep me from repeating myself.
I have a bunch of zones in Cloudlfare that I want to manage. These zones will all have very similar settings and I want my .tf
files to be both short and readable.
Lets say I have example1.com example2.com example3.com... I add them with the following code:
resource "cloudflare_zone" "example1"{
zone = "example1.com"
}
resource "cloudflare_zone" "example2"{
zone = "example2.com"
}
resource "cloudflare_zone" "example3"{
zone = "example3.com"
}
So far so good.
Now I want to apply some identical settings to all my zones using the cloudflare_zone_settings_override
provider.
Looking at the documentation this is straight forward for one zone. But I would rather not have to do this for each zone:
resource "cloudflare_zone_settings_override" "example1" {
name = "$example1.com"
settings {
brotli = "on"
security_level = "high"
opportunistic_encryption = "on"
automatic_https_rewrites = "on"
mirage = "on"
waf = "on"
minify {
css = "on"
js = "off"
html = "off"
}
}
}
What is the best way to apply these to all (or some) of the zones in Cloudflare?
Thanks