【发布时间】:2020-06-01 19:30:13
【问题描述】:
我创建了一个简单的模块:
.
├── inputs.tf
└── main.tf
输入变量在inputs.tf中声明:
variable "workers" {
type = number
description = "Amount of spark workers"
}
variable "values_values_path" {}
main.tf 是:
resource "helm_release" "spark" {
name = "spark"
repository = "https://charts.bitnami.com/bitnami"
chart = "spark"
version = "1.2.21"
namespace = ...
set {
name = "worker.replicaCount"
value = var.workers
}
values = [
"${file("${var.custom_values_path}")}"
]
}
如您所见,我正在尝试部署 helm 版本。我想设置一个参数化为custom_values_path的自定义值文件:
.
├── main.tf
├── provider.tf
└── spark-values.yaml
我的main.tf 是:
module "spark" {
source = "../modules/spark"
workers = 1
custom_values_path = "./spark_values.yaml"
}
但是,我得到:
Error: Error in function call
on ../modules/spark/main.tf line 14, in resource "helm_release" "spark":
14: "${file("${var.custom_values_path}")}"
|----------------
| var.custom_values_path is "./spark_values.yaml"
Call to function "file" failed: no file exists at spark_values.yaml.
完整的目录结构是:
.
├── stash
│ ├── main.tf
│ ├── provider.tf
│ └── spark-values.yaml
└── modules
└── spark
├── inputs.tf
└── main.tf
当我执行terraform plan 时,我在./stash。
所以完整的命令应该是:
$ > cd ./stash $ stash > terraform 计划 错误:函数调用出错
on ../modules/spark/main.tf line 14, in resource "helm_release" "spark":
14: "${file("${var.custom_values_path}")}"
|----------------
| var.custom_values_path is "./spark_values.yaml"
Call to function "file" failed: no file exists at spark_values.yaml.
为什么我调用函数“文件”失败:没有文件存在?
【问题讨论】:
标签: terraform