1 | initial version |
In order to pass a list to helm using the terraform helm_release provider, you can use the list
type in your values
block. Here is an example:
resource "helm_release" "my_release" {
name = "my-release"
repository = "https://charts.example.com/"
chart = "my-chart"
values = {
my_list = list("item1", "item2", "item3")
}
}
In this example, we are passing a list called my_list
that contains three items to the helm chart. Note that we are using the list
function to create the list with the three items. You can replace the items with variables or other expressions if needed.
Once you have your list defined in the values
block, you can access it in your helm chart templates using the lookup
function. For example, to iterate over the list in a range
block, you can use the following code:
{{- range $i, $item := (lookup .Values "my_list") }}
{{ printf "Item %d: %s" $i $item }}
{{- end }}
This will output the three items in the list with their corresponding index.