Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect indentation in rendered tf map variable #1526

Open
ikarlashov opened this issue Nov 4, 2024 · 1 comment
Open

Incorrect indentation in rendered tf map variable #1526

ikarlashov opened this issue Nov 4, 2024 · 1 comment
Assignees
Labels

Comments

@ikarlashov
Copy link

Terraform, Provider, Kubernetes and Helm Versions

Terraform version: v1.3.9
Provider version: 2.16.1
Kubernetes version: 1.28

Affected Resource(s)

helm_release

Terraform Configuration Files

locals {
  ebs_tags = {
    a = "one"
    b = "two"
    c = "three"
  }
}

helm_release "ebs_csi_driver" {
...
values = [
....
  extraVolumeTags:
    ${yamlencode(local.ebs_tags)}
....
]
}

Debug Output

│ Error: ---> error converting YAML to JSON: yaml: line 6: did not find expected key controller:
│   extraVolumeTags:
│     "a": "one"
│ "b": "two"
│ "c": "three"

Steps to Reproduce

Declare a map of strings in terraform and pass it to helm_release.

Expected Behavior

controller:
  extraVolumeTags: 
     a: one
     b: two
     c: three

Actual Behavior

   extraVolumeTags:
     "a": "one"
 "b": "two"
 "c": "three"

Important Factoids

I also tried to declare a map of strings in different ways, including passing a YAML formatted map with <<YAML. Additionally, I rendered the map inside values by iterating through the Terraform map variable. However, nothing worked. The outcome is always the same: only the first line of the map is correctly indented.
Also:

variable "ebs_tags" {
  type = map(string)
  default = {
    a = "one"
    b = "two"
    c = "three"
  }
}
  
# https://github.com/kubernetes-sigs/aws-ebs-csi-driver
resource "helm_release" "ebs_csi_driver" {
  count = var.enable_ebs_csi_driver ? 1 : 0

  name        = "aws-ebs-csi-driver"
  namespace   = "kube-system"
  chart       = "aws-ebs-csi-driver"
  version     = "2.35.1"
  repository  = "https://kubernetes-sigs.github.io/aws-ebs-csi-driver"
  max_history = 5

  set {
    name = "controller.extraVolumeTags"
    value = "${jsonencode(var.ebs_tags)}"
  }

Results in:

│ Error: YAML parse error on aws-ebs-csi-driver/templates/controller.yaml: error converting YAML to JSON: yaml: line 81: did not find expected '-' indicator
│ 
│   with module.eks.helm_release.ebs_csi_driver[0],
│   on ../../k8s-system-aws-ebs-csi-driver.tf line 100, in resource "helm_release" "ebs_csi_driver":
│  100: resource "helm_release" "ebs_csi_driver" {
│ 

And rendered as:

controller:
  extraVolumeTags:
  - '"a":"one"'
  - '"b":"two"'
  - '"c":"three"'

References

Helm template that renders extraVolumeTags dict.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@ikarlashov
Copy link
Author

Could someone please look into the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants