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

How to set {} multiline string as a value? #1284

Open
CiucurDaniel opened this issue Oct 31, 2023 · 3 comments
Open

How to set {} multiline string as a value? #1284

CiucurDaniel opened this issue Oct 31, 2023 · 3 comments
Labels

Comments

@CiucurDaniel
Copy link

CiucurDaniel commented Oct 31, 2023

Terraform version, Kubernetes provider version and Kubernetes version

Terraform version: 1.6.2
Helm Provider version: 2.11.0
Kubernetes version: 1.27

Terraform configuration

resource "helm_release" "vault" {
  name      = "vault"
  chart     = local.vault_chart_path
  namespace = "vault"

  values = [
    file("./vault-values.yaml"),
    yamlencode({ chart_hash : local.chart_hash, })
  ]

  set {
    name = "server.ha.config"
    type = "string"
    value = templatefile("../helm-charts/vault-ha-config/vault-ha-config.hcl", {
      pgusername   = "someuser"
      pgpassword   = "somepassword"
      pgserverfqdn = "some server"
      pgdatabase   = "vault"
    })
  }

  depends_on = [kubernetes_manifest.vault_psql_init_job]
}

Values file portion which I try to overwrite:

server:
  ha:
    enabled: true
    replicas: 1

    # config is a raw string of default configuration when using a Stateful
    # deployment. Default is to use a Consul for its HA storage backend.
    # This should be HCL.
    config: |
      ui = true

      storage "postgresql" {
        connection_url = "postgres://{pgusername}:{pgpassword}@{pgfqdn}/{pgdatabase}"
        table = "vault_kv_store"
        ha_enabled = "true"
        ha_table = "vault_ha_locks"
      }

Question

As you can see under server.ha.config we have a HCL file. I try to replace that config with a file that I templated (in order to add the secrets) but it fails with error:

Error: error getting values: failed parsing key "server.ha.config" with value ui = true                                                                 
│                                                                                                                                                         
│ storage "postgresql" {                                                                                                                                  
│   connection_url = "postgres://{pgusername}:{pgpassword}{pgserverfqdn}/{pgdatabase}"                                                                    
│   table = "vault_kv_store"                                                                                                                              
│   ha_enabled = "true"                                                                                                                                   
│   ha_table = "vault_ha_locks"                                                                                                                           
│ }    

... rest of file                                                                                

How can we use set { } in order to set a multiline string in the values file?

@CiucurDaniel
Copy link
Author

Ok so if I just try to set a single line string it works:

set {
    name = "server.ha.config"
    type = "string"
    value = "this works"
  }

Then the question still remains how can I set a multiline string value?

@CiucurDaniel
Copy link
Author

This issue might be changed to a BUG it seems the provider has a hard time setting that value as it's a HCL. We should be able to use set to set different string values such as my use case or as another example setting the content of a config map data which a a script or HCL.

@gnusey
Copy link

gnusey commented Mar 27, 2024

@CiucurDaniel did you ever find a workaround?

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