【发布时间】:2019-03-17 09:16:14
【问题描述】:
terraform 是否提供这样的功能来覆盖变量值?假设我已经声明了下面给出的两个变量。
variable "foo" {}
variable "bar" { default = "false"}
foo 是强制性的,bar 分配有默认值 false。 terraform 中是否有任何 resoruce 可用,我可以在其中重新分配或覆盖 bar 值?我在resource 的角度问这个问题。我知道我可以使用 terraform-modules 来做到这一点。
我已经尝试过这种用法null_resource,但没有得到预期的结果。它仍然返回默认值。
resource "null_resource" "this" {
provisioner "local-exec" {
command = "echo ${var.env} > ${var.newvar}"
}
}
我还想在命令属性中运行curl。我需要使用“解释器”吗?如果是这样,那么它的价值是什么?
interpreter = ["shell","?"] 我应该传递什么值来在local-exec 供应商中执行curl 命令。
bash 脚本
function check_efs() {
curl -ls https://elasticfilesystem.us-east-1.amazonsaws.com
if [ $? -eq 0 ]; then
output=1
else:
output=0
}
function produce_output() {
value=$(output)
jq -n \
--arg is_efs_exist "$value" \
'{"is_efs_exist":$is_efs_exist}'
}
check_efs
produce_output
【问题讨论】:
-
你好@muneeb - 这真的是两个问题。请把第二个问题(关于'curl')放到它自己的问题中。谢谢!
-
抱歉,我不清楚 - 我的意思是它自己的 StackOverflow 问题。
-
我不确定我是否明白你想要什么。检查此github.com/hashicorp/terraform-aws-consul/blob/master/… 和github.com/hashicorp/terraform-aws-consul/blob/master/…。不确定你的用例,但也许有助于澄清。
标签: terraform terraform-provider-aws