Skip to content

Instantly share code, notes, and snippets.

@soerenmartius
Created February 27, 2025 11:45
Show Gist options
  • Save soerenmartius/c2e2e156cbc6a03cbc35cd0dbd673789 to your computer and use it in GitHub Desktop.
Save soerenmartius/c2e2e156cbc6a03cbc35cd0dbd673789 to your computer and use it in GitHub Desktop.
conditional code generation
globals {
generate_data_source_google_ip = true
}
generate_hcl "terramate_data.tf" {
lets {
condition = tm_try(global.generate_data_source_google_ip, true)
}
content {
tm_dynamic "resource" {
for_each = tm_toset(["domain"])
iterator = value
labels = ["dns_a_record_set", value.value]
content {
host = tm_ternary(true, "google.com", "facebook.com")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment