kubernetes 错误:阅读EKS群集():运行地形规划时找不到资源

fumotvh3  于 2023-04-11  发布在  Kubernetes
关注(0)|答案(1)|浏览(103)

我的terraform文件如下。

  • 模块eks版本:19.5.1
data "aws_eks_cluster" "cluster" {
  name = module.eks.cluster_name
}

data "aws_eks_cluster_auth" "cluster" {
  name = module.eks.cluster_name
}

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

module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = "19.5.1" //19.0 version created the ingress security group for us
...}

当运行'terraform plan'时,我得到错误:

│ Error: reading EKS Cluster (ccc): couldn't find resource
│ 
│   with data.aws_eks_cluster.cluster,
│   on main.tf line 7, in data "aws_eks_cluster" "cluster":
│    7: data "aws_eks_cluster" "cluster" {
│ 
╵
o7jaxewo

o7jaxewo1#

尝试删除数据资源并使用以下kubernetes提供程序:

provider "kubernetes" {
  host                   = module.eks.cluster_endpoint
  cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
  exec {
    api_version = "client.authentication.k8s.io/v1beta1"
    command     = "aws"
    args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name]
  }
}

相关问题