Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

produced an unexpected new value: .object: wrong final value type: attribute "apiVersion": string required. #110

Closed
ghost opened this issue Sep 5, 2020 · 5 comments · Fixed by #151
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Sep 5, 2020

Terraform Version and Provider Version

2020/09/05 09:02:52 [INFO] Terraform version: 0.13.0
2020/09/05 09:02:52 [INFO] Go runtime version: go1.14.2
2020/09/05 09:02:52 [INFO] CLI args: []string{"//bin/terraform", "-v"}
2020/09/05 09:02:52 [DEBUG] Attempting to open CLI config file: //.terraformrc
2020/09/05 09:02:52 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/09/05 09:02:52 [DEBUG] checking for credentials in "//.terraform.d/plugins"
2020/09/05 09:02:52 [DEBUG] checking for credentials in "//.terraform.d/plugins/darwin_amd64"
2020/09/05 09:02:52 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2020/09/05 09:02:52 [DEBUG] will search for provider plugins in //.terraform.d/plugins
2020/09/05 09:02:52 [DEBUG] ignoring non-existing provider search directory //Library/Application Support/io.terraform/plugins
2020/09/05 09:02:52 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2020/09/05 09:02:52 [INFO] CLI command args: []string{"version", "-v"}

Your version of Terraform is out of date! The latest version
is 0.13.2. You can update by downloading from https://www.terraform.io/downloads.html
Terraform v0.13.0

  • provider registry.terraform.io/hashicorp/google v3.37.0
  • provider registry.terraform.io/hashicorp/google-beta v3.37.0
  • provider registry.terraform.io/hashicorp/kubernetes-alpha v0.2.0

Kubernetes Version

kubectl version
Client Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.6-beta.0", GitCommit:"e7f962ba86f4ce7033828210ca3556393c377bcc", GitTreeState:"clean", BuildDate:"2020-01-15T08:26:26Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.12-gke.2", GitCommit:"fb7add51f767aae42655d39972210dc1c5dbd4b3", GitTreeState:"clean", BuildDate:"2020-06-01T22:20:10Z", GoVersion:"go1.12.17b4", Compiler:"gc", Platform:"linux/amd64"}

Server Version
1.17.9-gke.1503

Affected Resource(s)

Terraform Configuration Files

resource "kubernetes_manifest" "service_rabbitmq_instance_rabbitmq_svc" {
  provider = kubernetes-alpha
  depends_on = [
    kubernetes_manifest.customresourcedefinition_applications_app_k8s_io,
  ]

  manifest = {
    "apiVersion" = "v1"
    "kind"       = "Service"
    "metadata" = {
      "name"      = "rabbitmq-instance-rabbitmq-svc"
      "namespace" = var.namespace
      "labels" = {
        "app.kubernetes.io/component" = "rabbitmq-server"
        "app.kubernetes.io/name"      = "rabbitmq-instance"
      }
    }
    "spec" = {
      "ports" = [
        {
          "name"     = "amqp-tls"
          "port"     = 5671
          "protocol" = "TCP"
        },
        {
          "name"     = "clitool"
          "port"     = 25672
          "protocol" = "TCP"
        },
        {
          "name"     = "epmd"
          "port"     = 4369
          "protocol" = "TCP"
        },
        {
          "name"     = "http"
          "port"     = 15672
          "protocol" = "TCP"
        },
      ]
      "selector" = {
        "app.kubernetes.io/component" = "rabbitmq-server"
        "app.kubernetes.io/name"      = "rabbitmq-instance"
      }
      "type" = "ClusterIP"
    }
  }
}

Debug Output

Error: Provider produced inconsistent result after apply

When applying changes to
module.app.kubernetes_manifest.service_rabbitmq_instance_rabbitmq_svc,
provider "registry.terraform.io/hashicorp/kubernetes-alpha" produced an
unexpected new value: .object: wrong final value type: attribute "apiVersion":
string required.

This is a bug in the provider, which should be reported in the provider's own
issue tracker.

2020-09-05T08:56:57.662-0700 [DEBUG] plugin: plugin process exited: path=.terraform/plugins/registry.terraform.io/hashicorp/kubernetes-alpha/0.2.0/darwin_amd64/terraform-provider
-kubernetes-alpha_v0.2.0_x5 pid=80172
2020-09-05T08:56:57.662-0700 [DEBUG] plugin: plugin exited

@ghost ghost added the bug Something isn't working label Sep 5, 2020
@ykyr
Copy link

ykyr commented Sep 17, 2020

I have exact same problem with a Service Kubernetes resource.

Steps to reproduce:

  • service.yaml
apiVersion: v1
kind: Service
metadata:
  name: dummy-test
  namespace: ${NAMESPACE}
spec:
  type: ClusterIP
  selector:
    name: app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
  • main.tf
terraform {
  required_version = ">= 0.13"
  required_providers {
    kubernetes-alpha = {
      source = "hashicorp/kubernetes-alpha"
    }
  }
}

provider "kubernetes-alpha" {
  config_path = "~/.kube/config"
}

resource "kubernetes_manifest" "dummy_test" {
  provider = kubernetes-alpha

  manifest = yamldecode(templatefile("service.yaml", {
    NAMESPACE = "default",
  }))
}

Error output:

kubernetes_manifest.dummy_test: Creating...

Error: Provider produced inconsistent result after apply

When applying changes to kubernetes_manifest.dummy_test, provider
"registry.terraform.io/hashicorp/kubernetes-alpha" produced an unexpected new
value: .object: wrong final value type: attribute "apiVersion": string
required.

This is a bug in the provider, which should be reported in the provider's own
issue tracker

@alexsomesan
Copy link
Member

Hi all,

Unfortunately this is a known issue specific to ClusterIP type services. The problem is the extra "clusterIP" attribute returned by the API server where the value of the IP is set.

This will be resolved when the local planning mode is completed, which is type-complete to the Kubernetes API spec and all attributes will be accounted for at plan time. It's being worked on here: #41

In the mean time, the workaround is to set the value for "clusterIP" in the TF manifest, like this:

resource "kubernetes_manifest" "test" {
  provider = kubernetes-alpha

  manifest = {
    "apiVersion" = "v1"
    "kind"       = "Service"
    "metadata" = {
      "name"      = "test"
      "namespace" = "default"
    }
    "spec" = {
      "type" = "ClusterIP"
      "selector" = {
        "app"      = "name"
      }
      "clusterIP" = "10.3.247.122"
      "ports" = [
        {
          "port"     = 80
          "protocol" = "TCP"
          "targetPort" = 8080
        },
      ]
    }
  }
}

@ykyr
Copy link

ykyr commented Oct 9, 2020

Thank you @alexsomesan for the explanation.

@aareet aareet linked a pull request Jan 25, 2021 that will close this issue
2 tasks
@va3093
Copy link

va3093 commented Feb 3, 2021

I just resorted to temporarily using the main kubernetes provider for services.

@ghost
Copy link

ghost commented Apr 8, 2021

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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
3 participants