在terraform文档中,它显示了如何使用模板.有没有办法将此渲染输出记录到控制台?
https://www.terraform.io/docs/configuration/interpolation.html#templates
resource "template_file" "example" {
template = "${hello} ${world}!"
vars {
hello = "goodnight"
world = "moon"
}
}
output "rendered" {
value = "${template_file.example.rendered}"
}
Run Code Online (Sandbox Code Playgroud)
你需要运行terraform apply
再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!
Run Code Online (Sandbox Code Playgroud)
小智 5
仔细观察,这是数据而不是资源
data "template_file" "example" {
template = "${file("templates/greeting.tpl")}"
vars {
hello = "goodnight"
world = "moon"
}
}
output "rendered" {
value = "${data.template_file.example.rendered}"
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5149 次 |
最近记录: |