Terraform-provider-helm: How to pass in a list in set ?

Created on 9 Oct 2018  路  2Comments  路  Source: hashicorp/terraform-provider-helm

Using the nginx ingress chart for example, I am having troubles figuring out how to pass into the set argument of a helm_release, a list of annotations.

It would be great to see some more documentation, as lists are passed into help in a specific way but with terraform it's even trickier.

For example we keep getting this error:
helm_release.nginx-ingress-internal: rpc error: code = Unknown desc = YAML parse error on nginx-ingress/templates/controller-service.yaml: error unmarshaling JSON: json: cannot unmarshal object into Go struct field .annotations of type string

resource "helm_release" "nginx-ingress-internal" {
  name      = "${var.environment}-nginx-ingress-internal"
  chart     = "stable/nginx-ingress"
  version   = "0.19.0"
  namespace = "${kubernetes_namespace.nginx.id}"
  keyring   = ""                                          # disabled

  set {
    name  = "controller.service.loadBalancerIP"
    value = "${google_compute_address.nginx-ingress-internal.address}"
  }

  set {
    name  = "controller.service.externalTrafficPolicy"
    value = "Local"
  }

  set {
    name  = "controller.service.annotations.cloud.google.com/load-balancer-type"
    value = "Internal"
  }
}

Most helpful comment

For a cloud.google.com/load-balancer-type: Internal annotation you need to escape the dots in the "cloud.google.com" namespace parts like so:

  set {
    name  = "controller.service.annotations.cloud\\.google\\.com/load-balancer-type"
    value = "Internal"
  }

Otherwise it will be interpreted as this:

controller:
  service:
    annotations:
      cloud:
        google:
          com/load-balancer-type: Internal

All 2 comments

For a cloud.google.com/load-balancer-type: Internal annotation you need to escape the dots in the "cloud.google.com" namespace parts like so:

  set {
    name  = "controller.service.annotations.cloud\\.google\\.com/load-balancer-type"
    value = "Internal"
  }

Otherwise it will be interpreted as this:

controller:
  service:
    annotations:
      cloud:
        google:
          com/load-balancer-type: Internal

Thanks very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eeeschwartz picture eeeschwartz  路  23Comments

obeyler picture obeyler  路  16Comments

rubenv picture rubenv  路  11Comments

colin-lyman picture colin-lyman  路  11Comments

dangarthwaite picture dangarthwaite  路  19Comments