I've created a straighforward module:
.
├── inputs.tf
└── main.tf
Input variables are declared in inputs.tf:
variable "workers" {
type = number
description = "Amount of spark workers"
}
variable "values_values_path" {}
main.tf is:
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}")}"
]
}
As you can see I'm trying to deploy a helm release. I'd like to set a custom values file parameterized as custom_values_path:
.
├── main.tf
├── provider.tf
└── spark-values.yaml
My main.tf here is:
module "spark" {
source = "../modules/spark"
workers = 1
custom_values_path = "./spark_values.yaml"
}
However, I'm getting:
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.
Complete directory structure is:
.
├── stash
│ ├── main.tf
│ ├── provider.tf
│ └── spark-values.yaml
└── modules
└── spark
├── inputs.tf
└── main.tf
When I perform terraform plan I'm in ./stash.
So complete commands would be:
$ > cd ./stash $ stash > terraform plan 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.
Why do I get Call to function "file" failed: no file exists?