admin管理员组

文章数量:1186702

I have a helm chart that i am trying to deploy with terraform. I have a requirement where i need to pass a condition in the values like i need to pass annotation ["test=foo"] for us-east-1 region and ["test=bar","test=foo"] for us-east-2 region. My main.tf looks like below

resource "helm_release" "chart_name" {
name       = "resource-name"
chart      = "${path.module}"
namespace  = "namespcae_name"
values = [

{
  flag = var.region == "us-east-1" ? ["test=foo"] : ["test=foo","test=bar"]
}

]

but i am getting an error Error: Invalid expression

I have a helm chart that i am trying to deploy with terraform. I have a requirement where i need to pass a condition in the values like i need to pass annotation ["test=foo"] for us-east-1 region and ["test=bar","test=foo"] for us-east-2 region. My main.tf looks like below

resource "helm_release" "chart_name" {
name       = "resource-name"
chart      = "${path.module}"
namespace  = "namespcae_name"
values = [

{
  flag = var.region == "us-east-1" ? ["test=foo"] : ["test=foo","test=bar"]
}

]

but i am getting an error Error: Invalid expression

Share Improve this question asked Jan 26 at 13:54 AbhinavAbhinav 811 silver badge11 bronze badges 1
  • I think this needs to be values = [flag = var.region == "us-east-1" ? ["test=foo"] : ["test=foo", "test=bar"] ]. Not sure if that would work though, but it might be worth a try. – Marko E Commented Jan 27 at 11:27
Add a comment  | 

1 Answer 1

Reset to default 1

The values parameter should be a list(string) type, and not a list(map(string)) type. You need to modify the value to a list(string) where each string is in "raw YAML format" (most easily accomplished with yamlencode function to encode from HCL2):

values = [yamlencode({flag = var.region == "us-east-1" ? ["test=foo"] : ["test=foo","test=bar"]})]

本文标签: kubernetes helmPass conditions in valuesyaml through terraformStack Overflow