Terraform-provider-kubernetes: Plan and Apply for namespaces is failing after upgrade to Terraform 0.14

Created on 4 Dec 2020  ·  4Comments  ·  Source: hashicorp/terraform-provider-kubernetes

Terraform Version and Provider Version


Terraform v0.14.0

  • provider registry.terraform.io/hashicorp/kubernetes v1.13.3

Affected Resource(s)

  • kubernetes_namespace

Terraform Configuration Files

variable "k8s_host" {
  type = string
}

variable "client_certificate" {
  type = string
}

variable "client_key" {
  type = string
}

variable "cluster_ca_certificate" {
  type = string
}
provider "kubernetes" {
  host                   = var.k8s_host
  client_certificate     = base64decode(var.client_certificate)
  client_key             = base64decode(var.client_key)
  cluster_ca_certificate = base64decode(var.cluster_ca_certificate)
}

resource "kubernetes_namespace" "test" {
  metadata {
    name        = "test"
    labels      = {}
    annotations = {}
  }
  lifecycle {
    ignore_changes = [
      metadata
    ]
  }
}

Debug Output

https://gist.github.com/loispostula/37c061ebcfc1534c0b868d0b6b00f298

Panic Output

Expected Behavior

Plan should return that there are no changes

Actual Behavior

Plan is crashing because:

  • Error: "metadata.0.resource_version": this field cannot be set
  • Error: "metadata.0.self_link": this field cannot be set
  • Error: "metadata.0.uid": this field cannot be set
  • Error: "metadata.0.generate_name": conflicts with metadata.0.name
  • Error: "metadata.0.generation": this field cannot be set
  • Error: "metadata.0.name": conflicts with metadata.0.generate_name

Steps to Reproduce

  1. On terraform 13.5:
    1.1 terraform init
    1.2 terraform apply -auto-approve
  2. On terraform 14.0:
    2.2 terraform init
    2.3 terraform apply -auto-approve

Important Factoids

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
bug upstream

All 4 comments

Hi @loispostula, I was able to replicate your issue. This appears to be caused by an upstream Terraform bug related to lifecycle. Please see https://github.com/hashicorp/terraform/pull/27141

It looks like the Terraform Core team is in the process of releasing a fix. I'll leave this comment open until the issue is resolved.

Terraform released v0.14.1 with a fix for this issue. Can you please try with the new version and let us know if this is resolved for you?

https://github.com/hashicorp/terraform/releases/tag/v0.14.1

Hi @redeux Tested with v0.14.2 and it's indeed fixed, thanks for identifying the issue

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings