The plugin returned an unexpected error from plugin.(*GRPCProvider).UpgradeResourceState

I am getting the issue when updating the ingress as I update my eks cluster from 1.21 to 1.22.

error:
he plugin returned an unexpected error from

│ plugin.(*GRPCProvider).UpgradeResourceState: rpc error: code = Unknown desc

│ = failed to determine resource GVK: cannot select exact GV from REST mapper

Hi @thakur5790,

You didn’t mention which provider you are using so I guessed AWS because I think when you say “EKS” you mean Amazon Elastic Kubernetes Service.

What you’ve found here seems like a bug in the provider, so I would suggest reporting it in the GitHub repository for the provider you are using:

Thanks for the reply, we are using k8s and helm provider to upgrade the ingress API version “v1beta1 to v1” as we are just updated the eks version from ‘1.21’ to ‘1.22’.
some.
the configuration we are using:

“provider “kubernetes” {
host = data.aws_eks_cluster.eks.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks.certificate_authority[0].data)
token = data.aws_eks_cluster_auth.eks.token
}
provider “helm” {
kubernetes {
host = data.aws_eks_cluster.eks.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks.certificate_authority[0].data)
token = data.aws_eks_cluster_auth.eks.token
}
}
#nginx controller
resource “helm_release” “ingress-nginx-controller” {
count = var.enable_nginx_controller ? 1 : 0
name = “ingress-nginx-controller”
namespace = “nginx-ingress”
repository = “Welcome - NGINX Ingress Controller
chart = “ingress-nginx”
version = “4.3.0”
create_namespace = true
values = [
{file("{var.nginx_controller_values_path}”)}”
]
}"

this actual error we are getting:

Error: Plugin error

│ with kubernetes_manifest.nginx-controller-ingress[0],

│ on main.tf line 342, in resource “kubernetes_manifest” “nginx-controller-ingress”:

│ 342: resource “kubernetes_manifest” “nginx-controller-ingress” {

│ The plugin returned an unexpected error from

│ plugin.(*GRPCProvider).UpgradeResourceState: rpc error: code = Unknown desc

│ = failed to determine resource GVK: cannot select exact GV from REST mapper

Error: Plugin error

│ with kubernetes_manifest.opensearch_ingress[0],

│ on main.tf line 619, in resource “kubernetes_manifest” “opensearch_ingress”:

│ 619: resource “kubernetes_manifest” “opensearch_ingress” {

│ The plugin returned an unexpected error from

│ plugin.(*GRPCProvider).UpgradeResourceState: rpc error: code = Unknown desc

│ = failed to determine resource GVK: cannot select exact GV from REST mapper

Ahh, I see.

In that case, the provider with the bug is hashicorp/kubernetes.

(At the very least, if this is a legitimate error then the provider really ought to be returning it as a user-facing diagnostic message in a way that is relevant to Terraform.)

Thanks for the update. In this case, who can help me please let me know.

@thakur5790 - Did you ever get this plugin error resolved? I am receiving the same plugin error on EKS v1.22 as well.

The plugin returned an unexpected error from plugin.(*GRPCProvider).UpgradeResourceState: rpc error: code = Unknown desc = failed to determine resource GVK: cannot select exact GV from REST mapper

resource "kubernetes_manifest" "external_metrics_crd" {
   manifest = {
     apiVersion = "apiextensions.k8s.io/v1"
     kind       = "CustomResourceDefinition"

     metadata = {
       name = "externalmetrics.metrics.aws"
     }

     spec = {
       group   = "metrics.aws"
       names = {
         kind     = "ExternalMetric"
         plural   = "externalmetrics"
         singular = "externalmetric"
       }
       scope = "Namespaced"
       versions = [{
          name    = "v1alpha1"
          served  = true
          storage = true
      }]
     }
   }
 }

Hi, I also facing with the same issue, someone have a solution for this?

│ Error: Plugin error
│ 
│ The plugin returned an unexpected error from
│ plugin.(*GRPCProvider).UpgradeResourceState: rpc error: code = Unknown desc
│ = failed to determine resource GVK: no matches for kind "DataPlane" in
│ group "linkerd.buoyant.io"

Your state file might be corrupted. It might have a module that doesn’t exist in your cluster already.
Try to delete, from the state file, the modules that are failing.
First list the modules with terraform state list, double check that your failing module is listed, then use terraform state rm <ADDRESS> to remove one module resource from the state. Do this for all resources that are failing.
Don’t forget to set the TF_WORKSPACE env var, or pass it at the beginning of the commands.