Using helm_release, how do I pass lists, arrays, or collections of data to the set{} block?

For example, per the helm chart documentation for Drupal, the default value for accessModes is ["ReadWriteOnce"] which translates to the following in the YAML:

...
accessModes
- ReadWriteOnce

When using the Terraform helm_release resource, the following do not work and the yaml file always shows the default from above:

  set {
    name  = "persistence.accessModes"
    value = "ReadWriteMany"
  }
  set {
    name  = "persistence.accessModes"
    value = "[\"ReadWriteMany\"]"
  }
  set {
    name  = "persistence.accessModes"
    value = "- ReadWriteMany"
  }

And how about annotations?

set {
    name = "ingress.annotations[0]"
    value = "cert-manager.io/cluster-issuer: letsencrypt-prod"
  }

or

set {
    name = "ingress.annotations[0].cert-manager.io/cluster-issuer"
    value = "letsencrypt-prod"
  }

The above does not work, nor does value = "cert-manager.io/cluster-issuer: letsencrypt-prod" or value = "cert-manager\\.io\\/cluster-issuer: letsencrypt-prod" they throw the following error:

Error: YAML parse error on drupal/templates/ingress.yaml: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal array into Go struct field .metadata.annotations of type map[string]string

What are the correct ways to set these types of values via the set{} block in helm_release?

3 Likes
set {
    name  = "persistence.accessModes[0]"
    value = "ReadWriteMany"
}
set {
    name = "ingress.annotations.cert-manager\\.io/cluster-issuer"
    value = "letsencrypt-prod"
}