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

values -> yamlencode -> value between bracket are added between simple quote #1492

Open
anthosz opened this issue Sep 19, 2024 · 0 comments
Open
Labels

Comments

@anthosz
Copy link

anthosz commented Sep 19, 2024

Terraform, Provider, Kubernetes and Helm Versions

Terraform version: 1.9.5
Provider version: 2.15.0
Kubernetes version: 1.30.0

Affected Resource(s)

Terraform Configuration Files

resource "helm_release" "prometheus" {
  name             = "prometheus"
  repository       = "https://prometheus-community.github.io/helm-charts"
  chart            = "prometheus"
  namespace        = "monitoring"
  create_namespace = true
  timeout          = 600
  wait_for_jobs    = true
  values = [
    yamlencode({
      server = {
        remoteWrite = [{
          url                   = "http://1.1.1.1:9090/api/v1/write"
          write_relabel_configs = [{
            source_labels = "[__name__]"
            action        = "drop"
            regex         = "(.*_(duration_seconds|seconds_total|sizes)_bucket)"
          }]
        }]
      }
    }),
  ]

Steps to Reproduce

  1. terraform apply

Expected Behavior

  1. kubectl -n monitoring describe cm/prometheus-server | grep -A 4 1.1.1.1
- url: http://1.1.1.1:9090/api/v1/write
  write_relabel_configs:
  - action: drop
    regex: (.*_(duration_seconds|seconds_total|sizes)_bucket)
    source_labels: [__name__]

Actual Behavior

  1. kubectl -n monitoring describe cm/prometheus-server | grep -A 4 1.1.1.1
- url: http://1.1.1.1:9090/api/v1/write
  write_relabel_configs:
  - action: drop
    regex: (.*_(duration_seconds|seconds_total|sizes)_bucket)
    source_labels: '[__name__]'

Description

The main issue is that when we use yamlencode and we complete a value by something between [ ], the string is included between simple quote. I tried also the trim function to force removal of these simple quote but no way.
If I check the plan or content in terraform.tfstate, there is no trace of simple quote, there is only double quote (string) like expected.
But once the configmap is created, this string is added between 2 simple quotes (that broke prometheus) and I don't understand what can explain this behavior :/

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
@anthosz anthosz added the bug label Sep 19, 2024
@appilon appilon removed their assignment Sep 19, 2024
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