gpt4 book ai didi

terraform - 在终端中打印 terraform 模板渲染输出?

转载 作者:行者123 更新时间:2023-12-04 07:34:29 25 4
gpt4 key购买 nike

在 terraform 文档中,它展示了如何使用模板。有什么方法可以将这个渲染输出记录到控制台?

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}"
}

最佳答案

您需要运行 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!

关于terraform - 在终端中打印 terraform 模板渲染输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37887888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com