I need to override a list of objects in a helm values file (using the terraform helm_release resource)
For example, imagePullSecrets is often a list of YAML objects which could be overwritten.
imagePullSecrets:
- name: artifactory-image-pull
This gave me some hope, but it only describes how to override a simple list, not a list of objects: Using Terraform's helm_release, how do I set array or list values?
I tried this with no luck:
set {
name = "imagePullSecrets[0].name"
value = var.image_pull_secret_name
}
I also tried to use set_list but this was mostly a stab in the dark:
set_list {
name = "imagePullSecrets"
value = [{ name : var.image_pull_secret_name }]
}
I've done something similar when deploying the helm release for argocd. Here's an example:
locals {
helm_extra_args = {
"repoServer.image.repository" = "..."
"repoServer.image.tag" = "..."
"repoServer.volumes[0].configMap.name" = "..."
"repoServer.volumes[0].name" = "..."
"repoServer.volumes[1].name" = "..."
"repoServer.volumes[1].secret.items[0].key" = "..."
"repoServer.volumes[1].secret.items[0].path" = "..."
"repoServer.volumes[1].secret.secretName" = "..."
}
}
resource "helm_release" "argocd" {
name = "argocd"
repository = "https://argoproj.github.io/argo-helm"
chart = "argo-cd"
version = "7.1.3"
dynamic "set" {
for_each = local.helm_extra_args
content {
name = set.key
value = set.value
}
}
}