Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS eks auth method failing in 2.6.0 #1469

Closed
jalavoy opened this issue Oct 21, 2021 · 9 comments
Closed

AWS eks auth method failing in 2.6.0 #1469

jalavoy opened this issue Oct 21, 2021 · 9 comments
Labels

Comments

@jalavoy
Copy link

jalavoy commented Oct 21, 2021

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 1.0.9
Kubernetes provider version: 2.6.0
Kubernetes version: 1.21

Affected Resource(s)

Provider Init

Terraform Configuration Files

provider "kubernetes" {
  host                     = module.eks.cluster_endpoint
  cluster_ca_certificate   = base64decode(module.eks.cluster_ca)
  config_context_auth_info = "aws"
  config_context_cluster   = "kubernetes"
  exec {
    api_version = "client.authentication.k8s.io/v1alpha1"
    args        = ["eks", "get-token", "--cluster-name", var.name, "--role", "${var.role_arn[var.environment]}"]
    command     = "aws"
  }
}

Debug Output

I'm not comfortable sharing this publicly since I'm not sure what (if any) sensitive info it has in it. Can provide it privately on request.

Panic Output

╷
│ Error: Provider configuration: cannot load Kubernetes client config
│
│   with provider["registry.terraform.io/hashicorp/kubernetes"],
│   on service_providers.tf line 47, in provider "kubernetes":
│   47: provider "kubernetes" {
│
│ cluster "kubernetes" does not exist

Steps to Reproduce

  1. terraform apply

Expected Behavior

Provider initializes correctly. This works with 2.5.0

Actual Behavior

Provider fails to initialize

@jalavoy
Copy link
Author

jalavoy commented Nov 12, 2021

This is still broken as of 2.6.1

@gurps1
Copy link

gurps1 commented Nov 26, 2021

Same issue on my side.

provider "kubernetes" {
  host                   = module.environments_eks.cluster_endpoint
  cluster_ca_certificate = base64decode(module.environments_eks.cluster_ca_certificate)
  config_context         = module.environments_eks.cluster_arn
  exec {
    api_version = "client.authentication.k8s.io/v1alpha1"
    command     = "aws"
    args = [
      "--region",
      var.region,
      "eks",
      "get-token",
      "--cluster-name",
      module.environments_eks.cluster_name
    ]
    env = {
      AWS_PROFILE = var.profile
    }
  }
}
╷
│ Error: Provider configuration: cannot load Kubernetes client config
│ 
│   with provider["registry.terraform.io/hashicorp/kubernetes"],
│   on providers.tf line 47, in provider "kubernetes":
│   47: provider "kubernetes" {
│ 
│ context "arn:aws:eks:xxxxxxx:xxxxxxx:cluster/xxxxxx-xxx-xxxxxxx" does not exist

works fine in 2.5.1 and 2.5.0, fails in 2.6.0 and 2.6.1

@johnmanjiro13
Copy link

johnmanjiro13 commented Dec 2, 2021

I ran into this problem but it was fixed with below code.

data "aws_eks_cluster" "default" {
  name = var.cluster_name
}

data "aws_eks_cluster_auth" "default" {
  name = var.cluster_name
}

provider "kubernetes" {
  host                   = data.aws_eks_cluster.default.endpoint
  cluster_ca_certificate = base64decode(data.aws_eks_cluster.default.certificate_authority[0].data)
  token                  = data.aws_eks_cluster_auth.default.token
}

@jalavoy
Copy link
Author

jalavoy commented Dec 2, 2021

We specifically need the exec for our workflow, which is the cause of this problem I believe.

@johnmanjiro13
Copy link

johnmanjiro13 commented Dec 5, 2021

Oh! I see.

@jalavoy
Copy link
Author

jalavoy commented Jan 27, 2022

This is still broken in 2.7.1. If I can provide any more information on this please let me know.

@yk-47
Copy link

yk-47 commented Mar 9, 2022

Same issue here, works in 2.5.1, broken from 2.6.0.

@jalavoy
Copy link
Author

jalavoy commented Mar 15, 2022

I believe this is fixed in 2.8.0 with the removal of config_context_auth_info and config_context_cluster

@jalavoy jalavoy closed this as completed Mar 15, 2022
@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants