Terraform and helm_release

Hi there.
I am trying to use helm_release to deploy elasticsearch filebeat in EKS cluster. It works fine with the default settings but when I need to pass different values I have problems. I red already docs and stuff but I am a bit confused.

let’s say this is my code in the resource helm_release…

Blockquote

resource "helm_release" "filebeat" {
 count = var.install_filebeat ? 1 : 0
  name       = "filebeat"
  repository = "https://helm.elastic.co"
  chart      = "filebeat"
  version    = "7.10.2"
  namespace  = var.monitoring_namespace


values = [
    "${file("values.yaml")}"
  ]
set {
    name  = "cloud.id"
    value = "MYID"
  }
  set {
    name  = "cloud.auth"
    value = "MYADMIN:MYPASS"
  }
}

Given the above it doesn’t pass the values to the helm. Actually it gives me an error that I couldn’t find the file values.yaml

Can you explain why? I don’t want to create a localfile but just pass the values to the helm in order to start!
Cheers

anyone on this issue?
Cheers

That code is telling Terraform to read the file values.yaml and use the content to pass to the Helm provider.

If you don’t have such a file just remove that values parameter section.

Thanks Stuart.
But if I want to change some parameters in the helm values file (e.g…clou.id and auth or any other parameters)…what should I do? Do I need to create a template to pass to helm?
I thought with the set command in the helm_release I would pass those params…am I wrong?

Cheers

Yes you can use the set (and set_sensitive) blocks. They are the equivalent of using the --set command line option if you ran the helm command.

I tried everything without errors this time but still can’t change the values for helm. It keeps having the default filebeat.yml and nothing happens.

any idea why?

What is the code you are trying?

Thanks Stuart for the reply.
So below is th TF code…

resource “helm_release” “filebeat” {
count = var.install_filebeat ? 1 : 0
name = "filebeat"
repository = "https://helm.elastic.co"
chart = "filebeat"
version = "7.10.2"
namespace = var.monitoring_namespace

values = [templatefile("${path.module}/values.tmpl", {
cid: “omitted”,
cau: " omitted"
})]
}

AND below the template

filebeat.inputs:
- type: container
paths:
- /var/log/containers/*.log
processors:
- add_kubernetes_metadata:
matchers:
- logs_path:
logs_path: "/var/log/containers/"
cloud.id: {cid}** **cloud.auth: {cau}

So no errors on TF plan and apply… but then the pod doesn’t get the new configuration at all neither restart or do anything. I also tried to scratch and rebuild everything but still nothing.

What’d be the problem? Obviously I’m doing something wrong but not sure what

Cheers

Is that template supposed to be setting the filebeat config file?

If so, you don’t seem to be using the correct configuration (helm-charts/filebeat at master · elastic/helm-charts · GitHub). It looks like you are wanting to set deployment.filebeatConfig

thanks Stuart. That’s right. I forgot to use the following in the template

filebeatConfig:
filebeat.yml: |

after adding those it’s picking up my conf.

Cheers