Error: Get "http://localhost/api/v1/namespaces/*": dial tcp 127.0.0.1:80: connect: connection refused during eks cluster upgrade

We have eks cluster created using terraform module. We are trying to upgrade the cluster by changing the current version from 1.25 to 1.26 in the config tfvars. During terraform plan running in Jenkins pipeline its throwing error with the subject above thus we cannot proceed to upgrade it.

We noticed as well that during plan the cluster endpoint is “known after apply” I think maybe this is the reason why k8s related resources is getting connection refused while trying to read the state file. We can’t seem escape in this scenario. Your help would greatly appreciated.

namespace.tf
image

#PROVIDER:

#PLAN:
Snipped Plan:


Version:

  • Terraform v1.6.4
  • hashicorp/aws v4.67.0…
  • hashicorp/aws v4.67.0 (signed by HashiCorp)
  • hashicorp/kubernetes v2.24.0…
  • hashicorp/kubernetes v2.24.0 (signed by HashiCorp)