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

Syntax issue in kube-prometheus-stack module #391

Open
alexhollis opened this issue Dec 1, 2022 · 1 comment
Open

Syntax issue in kube-prometheus-stack module #391

alexhollis opened this issue Dec 1, 2022 · 1 comment

Comments

@alexhollis
Copy link

In the kube-prometheus-stack TF module - https://github.com/ManagedKube/kubernetes-ops/tree/main/terraform-modules/aws/helm/kube-prometheus-stack

There is a syntax issue that causes Terraform to fail if the module is included as a module dependency in another.
i.e. -

module "kube-prometheus-stack" {
  source = "github.com/ManagedKube/kubernetes-ops/terraform-modules/aws/helm/kube-prometheus-stack"

  helm_values = file("${path.module}/values.yaml")

  depends_on = [
    data.terraform_remote_state.eks
  ]
}

The error that occurs is this:

Waiting for the plan to start...

Terraform v1.2.6
on linux_amd64
Initializing plugins and modules...

│ Error: Invalid function argument

│ on .terraform/modules/kube-prometheus-stack/terraform-modules/aws/helm/kube-prometheus-stack/main.tf line 17, in resource "helm_release" "helm_chart":
│ 17: templatefile("./values_local.yaml", {
│ 18: enable_grafana_aws_role = var.enable_iam_assumable_role_grafana
│ 19: aws_account_id = var.aws_account_id
│ 20: role_name = local.k8s_service_account_name
│ 21: }),

│ Invalid value for "path" parameter: no file exists at
│ "./values_local.yaml"; this function works only with files that are
│ distributed as part of the configuration source code, so if this file will
│ be created by a resource in this configuration you must instead obtain this
│ result from an attribute of that resource.

Operation failed: failed running terraform plan (exit 1)

This is due to this line of code: https://github.com/ManagedKube/kubernetes-ops/blob/main/terraform-modules/aws/helm/kube-prometheus-stack/main.tf#L17

resource "helm_release" "helm_chart" {
  chart            = "kube-prometheus-stack"
  namespace        = var.namespace
  create_namespace = "true"
  name             = var.chart_name
  version          = var.helm_version
  verify           = var.verify
  repository       = "https://prometheus-community.github.io/helm-charts"

  values = [
    # templatefile("${path.module}/values.yaml", {
--> templatefile("./values_local.yaml", {
      enable_grafana_aws_role = var.enable_iam_assumable_role_grafana
      aws_account_id          = var.aws_account_id
      role_name               = local.k8s_service_account_name
    }),
    var.helm_values,
  ]
}

Changing this line to:

templatefile("${path.module}/values_local.yaml", {

fixes the issue.

@sekka1
Copy link
Collaborator

sekka1 commented Dec 15, 2022

Thanks. Will add this change =)

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

No branches or pull requests

2 participants