terraform-provider-helm
terraform-provider-helm copied to clipboard
Special character with yamlencode with helm values
Terraform, Provider, Kubernetes and Helm Versions
Terraform version: 1.1.9
Provider version: 2.5.1
Kubernetes version: aks v1.22.6
Affected Resource(s)
- helm_release
Terraform Configuration Files
set {
name = "config"
value = yamlencode({
modules = {
http_2xx = {
prober = "http"
timeout = "5s"
http = {
valid_http_versions = ["HTTP/2.0"]
follow_redirects = false
preferred_ip_protocol = "ip4"
method = "HEAD"
fail_if_not_ssl = true
enable_http2 = true
}
}
}
})
}
Debug Output
+ set {
+ name = "config"
+ value = <<-EOT
"modules":
"http_2xx":
"http":
"enable_http2": true
"fail_if_not_ssl": true
"follow_redirects": false
"method": "HEAD"
"preferred_ip_protocol": "ip4"
"valid_http_versions":
- "HTTP/2.0"
"prober": "http"
"timeout": "5s"
EOT
}
Steps to Reproduce
-
terraform apply
Expected Behavior
"modules":
"http_2xx":
"http":
"enable_http2": true
"fail_if_not_ssl": true
"follow_redirects": false
"method": "HEAD"
"preferred_ip_protocol": "ip4"
"valid_http_versions":
- "HTTP/2.0"
"prober": "http"
"timeout": "5s"
Actual Behavior
|
"modules":
"http_2xx":
"http":
"enable_http2": true
"fail_if_not_ssl": true
"follow_redirects": false
"method": "HEAD"
"preferred_ip_protocol": "ip4"
"valid_http_versions":
- "HTTP/2.0"
"prober": "http"
"timeout": "5s"
Hi @KlemenDanfoss – I'm not sure if I understand your issue. Is the special character you are referring to the pipe |
at the start of your second snippet? This character is used in YAML for multi-line strings. By using yamlencode
you are creating a string value that contains YAML rather than specifying YAML directly, so that might be why you are seeing it appear with the |
character once it's rendered.
Hi, yes, I'm talking about the pipe at the start of my second snippet.
So, basically, yamlencode is not the right way to go to define a 'multiline variable'?
@KlemenDanfoss yeah, you might want to try using the values
attribute instead, which accepts arbitrary YAML like this:
values = [
yamlencode({
config = {
modules = {
http_2xx = {
prober = "http"
timeout = "5s"
http = {
valid_http_versions = ["HTTP/2.0"]
follow_redirects = false
preferred_ip_protocol = "ip4"
method = "HEAD"
fail_if_not_ssl = true
enable_http2 = true
}
}
}
}
})
]
Hi,
thanks for the reply. I understand, I also found this.
If this doesn't 'work' then maybe we could add this to documentation (somehow) so other people don't get confused as well.
I'm facing a related issue. I'm trying to parameterize a value in a chart which uses Helm provider.
Excerpt from my code:
helm_config = {
chart = ...
values = [
yamlencode({
spawnerUiConfig = {
spawnerFormDefaults = {
image = {
...
}
}
}
})
]
}
I'm trying to render the value like this:
apiVersion: v1
kind: ConfigMap
data:
spawner_ui_config.yaml: |
{{ .Values.spawnerUiConfig }}
But this is what is applied:
data:
spawner_ui_config.yaml: |
map[spawnerFormDefaults:map[image:map[
Desired output would be this:
data:
spawner_ui_config.yaml: |
spawnerFormDefaults:
image:
Any ideas how to get rendered this YAML correctly?
I'm facing a related issue. I'm trying to parameterize a value in a chart which uses Helm provider.
Excerpt from my code:
helm_config = { chart = ... values = [ yamlencode({ spawnerUiConfig = { spawnerFormDefaults = { image = { ... } } } }) ] }
I'm trying to render the value like this:
apiVersion: v1 kind: ConfigMap data: spawner_ui_config.yaml: | {{ .Values.spawnerUiConfig }}
But this is what is applied:
data: spawner_ui_config.yaml: | map[spawnerFormDefaults:map[image:map[
Desired output would be this:
data: spawner_ui_config.yaml: | spawnerFormDefaults: image:
Any ideas how to get rendered this YAML correctly?
Hi, I'm facing same issue, did you solve it?
Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you!