错误:读取 EKS Cluster ():运行 terraform plan 时找不到资源

s00*_*433 1 kubernetes terraform amazon-eks

我的地形文件如下。

\n
    \n
  • 模块eks版本:19.5.1
  • \n
\n
data "aws_eks_cluster" "cluster" {\n  name = module.eks.cluster_name\n}\n\ndata "aws_eks_cluster_auth" "cluster" {\n  name = module.eks.cluster_name\n}\n\nprovider "kubernetes" {\n  host                   = data.aws_eks_cluster.cluster.endpoint\n  cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)\n  token                  = data.aws_eks_cluster_auth.cluster.token\n}\n\nmodule "eks" {\n  source  = "terraform-aws-modules/eks/aws"\n  version = "19.5.1" //19.0 version created the ingress security group for us\n...}\n
Run Code Online (Sandbox Code Playgroud)\n

运行“terraform plan”时,出现错误:

\n
\n\xe2\x94\x82 Error: reading EKS Cluster (ccc): couldn\'t find resource\n\xe2\x94\x82 \n\xe2\x94\x82   with data.aws_eks_cluster.cluster,\n\xe2\x94\x82   on main.tf line 7, in data "aws_eks_cluster" "cluster":\n\xe2\x94\x82    7: data "aws_eks_cluster" "cluster" {\n\xe2\x94\x82 \n\xe2\x95\xb5\n
Run Code Online (Sandbox Code Playgroud)\n

Dle*_*aim 7

我添加depends_on到我的数据列并且它起作用了。

data "aws_eks_cluster" "calocalc-cluster" {
  name = var.cluster_name
  depends_on = [module.eks.cluster_name]
}
Run Code Online (Sandbox Code Playgroud)


小智 5

尝试删除数据资源并使用以下 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]
  }
}
Run Code Online (Sandbox Code Playgroud)