Terraform-provider-kubernetes: resource kubernetes_namespace should have a "name" output

Created on 24 May 2018  路  1Comment  路  Source: hashicorp/terraform-provider-kubernetes

In order to have dependency between a kuberentes_namespace resource and another resource that uses this namespace, such as kubernetes_pod, kuberentes_namespace resource should expose a name output.

The diff below describes the difference between the current way of using a kubernetes namespace in terraform and the way I propose to use a kubernetes namespace:

resource "kubernetes_namespace" "default" {
  metadata {
    name = "my-namespace"
  }
}

resource "kubernetes_pod" "my-pod" {
  metadata {
    name = "pod1"
-    namespace = "my-namespace"
+    namespace = "${kubernetes_namespace.default.name}"
  }
  spec {
    ...
  }
-  depends_on = ["kubernetes_namespace.default"]
}

Most helpful comment

I'm sorry, I can get it with the "id" output of the namespace resource:

resource "kubernetes_namespace" "default" {
  metadata {
    name = "my-namespace"
  }
}

resource "kubernetes_pod" "my-pod" {
  metadata {
    name = "pod1"
    namespace = "${kubernetes_namespace.default.id}"
  }
  spec {
    ...
  }
}

>All comments

I'm sorry, I can get it with the "id" output of the namespace resource:

resource "kubernetes_namespace" "default" {
  metadata {
    name = "my-namespace"
  }
}

resource "kubernetes_pod" "my-pod" {
  metadata {
    name = "pod1"
    namespace = "${kubernetes_namespace.default.id}"
  }
  spec {
    ...
  }
}
Was this page helpful?
0 / 5 - 0 ratings