In the terraform docs it shows how to use a template. Is there any way to log this rendered output the console?
https://www.terraform.io/docs/configuration/interpolation.html#templates
data "template_file" "example" {
template = "${hello} ${world}!"
vars {
hello = "goodnight"
world = "moon"
}
}
output "rendered" {
value = "${template_file.example.rendered}"
}
The template_file data source renders a template from a template string, which is usually loaded from an external file. In Terraform 0.12 and later, the templatefile function offers a built-in mechanism for rendering a template from a file.
rendered - The final rendered template. The value of the policy will be the content of the template after terraform renders it.
The template provider exposes data sources to use templates to generate strings for other Terraform resources or outputs. Use the navigation to the left to read about the available data sources.
You need to run terraform apply
then terraform output rendered
$ terraform apply
template_file.example: Creating...
rendered: "" => "<computed>"
template: "" => "${hello} ${world}!"
vars.#: "" => "2"
vars.hello: "" => "goodnight"
vars.world: "" => "moon"
template_file.example: Creation complete
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.
State path: terraform.tfstate
Outputs:
rendered = goodnight moon!
$ terraform output rendered
goodnight moon!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With