Search code examples
terraformkubernetes-helmterraform-helm-provider

How do I pass a nested list to the helm_release resource?


I need this config:

ingress:
  hosts:
    - host: test.example.io
      paths: [/path]

I attempted this and got an error:

  set_list {
    name  = "ingress.hosts"
    value = ["{host: *, paths [/*]}"]
  }

Error: failed parsing key "ingress.hosts" with value {host: *, paths [/*]}, key "}" has no value

EDIT

I wound up just yamlencode-ing a terraform map- but a yaml file would have been a lot more readable:

  values = [
    yamlencode(var.terraform_map_var)
  ]

Solution

  • I will show a way that will help you to do that easily, without any complexity of setting nested values in helm_release terraform resource.

    In this example we will see how to deploy grafana helm release using terraform helm_release resource. You can test by deploying a grafana release. We're going to use values.yaml file to configure the release.

    Example: Prometheus helm release terraform config

    resource "helm_release" "prometheus" {
      name       = "prometheus"
      chart      = "prometheus"
      repository = "https://prometheus-community.github.io/helm-charts"
      version    = "14.8.0"
      namespace  = "prometheus"
      values = [
      "${file("values.yaml")}"
      ]
    } 
    

    Prometheus values.yaml config (just put the conf that you want in this file)

    server:
      service:
        type: ClusterIP
    

    This example works well from my side. I hope it will resolve your problem