Overview
When using the Terraform Enterprise Flexible Deployment Options Helm chart, the following error may occur if the chart values are improperly formatted or otherwise invalid.
Error: YAML parse error on terraform-enterprise/templates/filename.yaml: error converting YAML to JSON: yaml: line ##: mapping values are not allowed in this context
Problem
Helm is a templating engine. Kubernetes manifests are templated with data from values.yaml
, making it possible to introduce invalid YAML syntax to the final output. The line and file in the error refer to the templated output, so the chart should be templated, then the output file can be checked to be a valid Kubernetes manifest.
Solution
Template the chart
The --debug
flag is important here as it allows the template to complete regardless of the validity of the YAML output.
helm repo add hashicorp https://helm.releases.hashicorp.com helm repo update helm template --output-dir out --debug <release_name> hashicorp/terraform-enterprise -f values.yaml
Cross-reference the chart with the chart values
Using the templated manifests under out/
, go to the file name and line that were present in the error. Some code editors may visibly mark an invalid Kubernetes manifest. If the issue is difficult to identify, the templates themselves (https://github.com/hashicorp/terraform-enterprise-helm/tree/main/templates) may be referenced to give context to how the manifest was templated based on the values.yaml
.
Additional Context
- https://developer.hashicorp.com/terraform/enterprise/flexible-deployments
- https://github.com/hashicorp/terraform-enterprise-helm
- https://helm.sh/docs/helm/helm_template/
- https://helm.sh/docs/intro/cheatsheet/