Error in building k8 objects when using terraform to create filebeat as a resource

I am trying to do something similar to this post over at Hashicorp: Terraform and helm_release - #7 by stuart-c - Essentially, installing filebeat on a kubernetes cluster inside AKS.

Here’s my filebeat config file (filebeat.yaml)

filebeatConfig:
  filebeat.yml: |
    filebeat.inputs:
      - type: log
        paths:
          - /usr/share/filebeat/logs/filebeat
    output.elasticsearch:
      hosts: '["my_host_url"]'
      api_key: "${EC_API_KEY}"

and referencing it in my filebeat.tf as below

resource "helm_release" "filebeat" {
  name       = "filebeat"
  repository = "https://helm.elastic.co"
  chart      = "filebeat"
  version    = "7.9.3"
  namespace  = "kube-system"

  values = [templatefile("${path.module}/filebeat.yaml", 
  {
    EC_API_KEY = var.EC_API_KEY
  })]


  depends_on = [
    ec_deployment.global
  ]

}

when I run terraform apply , I get this error:

helm_release.filebeat: Creating...
╷
│ Error: unable to build kubernetes objects from release manifest: [unable to recognize "": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1", unable to recognize "": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"]
│ 
│   with helm_release.filebeat,
│   on filebeat.tf line 1, in resource "helm_release" "filebeat":
│    1: resource "helm_release" "filebeat" {
│ 
╵

I’m not sure where to go from here. I also think I should be referencing the aks cluster info somewhere in my filebeats.tf, but not sure where.

Any tips would be appreciated. Thank you

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.