Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Terraform: conditionally reference a data source that may or may not exist
variable "yes" { default = true }
data "template_file" "maybe" {
count = "${ var.yes == false ? 0 : 1 }"
template = "YES"
}
output "maybe" {
value = "${ var.yes == false ? "" : element(concat(data.template_file.maybe.*.rendered, list("")), 0) }" # <-- :_(
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.