Skip to content

Failed to get namespace #2558

@MonicaMagoniCom

Description

@MonicaMagoniCom

Terraform version: 1.7.4
Kubernetes provider version: 2.31.0
Kubernetes version: 1.28

I have a module called 'kube' where I create the following namespace:

resource "kubernetes_namespace" "pulsar-ns" {
  metadata {
    name = "pulsar2"
  }
}

Then in another module (which has a dependency on the kube module), so it is applied after the 'kube' module, I do:

resource "terraform_data" "prepare-pulsar-helm-release" {
  provisioner "local-exec" {
    command     = "./prepare_helm_release.sh -k pulsar -s -n ${var.pulsar-ns}"
    interpreter = ["bash", "-c"]
    working_dir = path.module
  }
  depends_on = [var.pulsar-ns]
}

When doing terraform apply, it correctly creates the namespace, but the local-exec fails with error (even though the ns exists):

exit status 1. Output: error: failed to get namespace 'pulsar2'
│ please check that this namespace exists, or use the '-c' option to create it

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions