Created
November 29, 2019 13:10
-
-
Save kosyfrances/41d04ad7945da4fce8641ad7013ebfca to your computer and use it in GitHub Desktop.
Render terraform template to local file tested on Terraform v0.12.16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
our_rendered_content = templatefile("${path.module}/yourtemplatefile.tmpl", { yourvars = var.yourvars }) | |
} | |
resource "null_resource" "local" { | |
triggers = { | |
template = local.our_rendered_content | |
} | |
# Render to local file on machine | |
# https://github.com/hashicorp/terraform/issues/8090#issuecomment-291823613 | |
provisioner "local-exec" { | |
command = format( | |
"cat <<\"EOF\" > \"%s\"\n%s\nEOF", | |
var.output_file, | |
local.our_rendered_content | |
) | |
} | |
} |
Thanks! Still works in v1.0.11
🙌 Still works in v1.3.7
Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good example of this use-case, thanks :)