banzaicloud/terraform-provider-k8s

expected "namespace::groupVersion::kind::name" with 0.8.3 and terraform-0.13

Andor opened this issue · 1 comments

Andor commented

Describe the bug

I have code:

data "template_file" "priority_class_low" {
  template = file(
    "${path.module}/templates/priority-class.yaml.tpl"
  )
  vars = {
    name           = "low"
    value          = "1000"
    global_default = "false"
    description    = "For pods you don't really care about"
  }
}

resource "k8s_manifest" "priority_class_low" {
  content = data.template_file.priority_class_low.rendered
}

And template:

apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
  name: ${name}
value: ${value}
globalDefault: ${global_default}
description: "${description}"

With Terraform 0.12 and provider 0.5.0 everything was OK.

Now
After update from tf-0.12 and provider 0.5.0 to tf-0.13 and provider 0.8.3 I have the issue:

Error: unexpected ID format ("/apis/scheduling.k8s.io/v1beta1/priorityclasses/low"), expected "namespace::groupVersion::kind::name".

Here is existing resource in kubernetes:

$ kubectl get priorityclasses/low -o yaml
apiVersion: scheduling.k8s.io/v1
description: For pods you don't really care about
kind: PriorityClass
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"scheduling.k8s.io/v1","description":"For pods you don't really care about","globalDefault":false,"kind":"PriorityClass","metadata":{"annotations":{},"name":"low"},"value":1000}
  creationTimestamp: "2019-10-22T11:17:18Z"
  generation: 1
  name: low
  resourceVersion: "43187495"
  selfLink: /apis/scheduling.k8s.io/v1/priorityclasses/low
  uid: 8237f8b1-f4bd-11e9-9951-0abbc3022b5e
value: 1000 

Here is the same resource in terraform state:

    {
      "module": "module.eks_cluster",
      "mode": "managed",
      "type": "k8s_manifest",
      "name": "priority_class_low",
      "provider": "module.eks_cluster.provider[\"registry.terraform.io/banzaicloud/k8s\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "content": "apiVersion: scheduling.k8s.io/v1\nkind: PriorityClass\nmetadata:\n  name: low\nvalue: 1000\nglobalDefault: false\ndescription: \"For pods you don't really care about\"\n",
            "id": "/apis/scheduling.k8s.io/v1beta1/priorityclasses/low"
          },
          "private": "...",
          "dependencies": [ ...
          ]
        }
      ]
    },

Steps to reproduce the issue:

  1. Apply the code with terraform-0.12 and provider 0.5.0;
  2. Upgrade terraform to 0.13 and provider to 0.8.3;
  3. Try to apply again.

Expected behavior

I expect the code will get resource definition from Kubernetes and correctly compare it with locally compiled resource from the template.

Additional context

I noticed there v1beta1 in resource id in the state because the resource was created with older Kubernetes version, but when I manually patch it to just v1 the error is the same.

Andor commented

duplicate #30