使用terraform helm_release提供程序传递列表到helm



我见过这个和另一个类似的问题,但不能让它工作使用Terraform's helm_release,我如何设置数组或列表值?

我的列表来自一个json文件,它是一个允许的组列表

locals {
app_groups = jsondecode(file("../../work/resources/gke/params/access_auths.json")).accessgroups[var.project][0].app_group
}
output "app_groups" {
value = local.app_groups
}

给- - - - - -

app_groups = [
"bigquery-team",
"devops-team",
]

主要。tf -

resource "helm_release" "oauth2proxy" {
name         = "oauth2proxy"
chart        = "../charts/oauth2proxy"
namespace    = kubernetes_namespace.oauth2proxy.metadata.0.name
set {
name  = "app_groups[0]"
value = "${local.app_groups}"
}
values = [
templatefile("../charts/oauth2proxy/oauth2proxy_values.yaml", {
projectID     = var.project
clusterName   = var.clusterName
})
]
}

在舵展开。当启动容器时,它需要进入-args

{{  range $v := .app_groups }}
- --allowed-group="{{ $v }}"
{{ end }}

但是我得到

Error: Incorrect attribute value type
on main.tf line 129, in resource "helm_release" "oauth2proxy":
129:     value = "${local.app_groups}"
────────────────
│ local.app_groups is tuple with 2 elements
│ Inappropriate value for attribute "value": string required.

问题是,它是一个元组,我希望它是一个元组,我不知道如何告诉tertransform或helm它应该是一个元组

我试过各种不同的"设置";和动态设置;但是没有任何进展。

value需要一个字符串。在Helm中,您可以使用{a, b, c}语法提供数组。要构建此语法,您可以使用join():

set {
name  = "app_groups"
value = "{${join(",", local.app_groups)}}"
}

这应该可以达到目的,并以{bigquery-team, devops-team}的形式提供app_groups作为数组。我不确定是否需要引号,但这可以很容易地添加。

最新更新