Skip to content

Instantly share code, notes, and snippets.

@phinze
Created December 16, 2015 20:43
Show Gist options
  • Save phinze/405c5ce109d2a7475844 to your computer and use it in GitHub Desktop.
Save phinze/405c5ce109d2a7475844 to your computer and use it in GitHub Desktop.
take a string like "a b c" and turn that in to "a", "b", "c" in the template
variable "input" {
default = "a b c"
}
resource "template_file" "json" {
template = "{ \"somekey\": [${list}] }"
vars {
list = "${join(", ", formatlist("\\"%s\\"", split(" ", var.input)))}"
}
}
output "rendered" {
value = "${template_file.json.rendered}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment