我已按照 hashiCorp 教程进行部署和 EKS 集群。使用他们的 tf 文件时,它会成功初始化。如果我在下面使用我的 tf 文件,它会为 terraform-aws-modules/eks 抛出一个错误,并且它为什么会这样做是没有意义的。
variable "region" {
default = "us-west-2"
description = "AWS region"
}
provider "aws" {
region = "us-west-2"
}
provider "kubernetes" {
host = data.eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
token = data.eks_cluster_auth.cluster.token
load_config_file = false
}
data "aws_availability_zones" "available" {}
data "eks_cluster" "cluster" {
name = module.eks.cluster_id
}
data "eks_cluster_auth" "cluster" {
name = module.eks.cluster_id
}
locals {
cluster_name = "development-eks-${random_string.suffix.result}"
}
resource "random_string" "suffix" {
length = 8
special = false
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
cluster_name = local.cluster_name
cluster_version = "1.17"
subnets = ["subnet-021510f2a4ad98fad","subnet-09ebbc7929c3859b4", "subnet-0a80ba106a29de364"]
vpc_id = "vpc-5b230723"
tags = {
environment = "development"
}
worker_groups = [
{
name = "worker-group-1"
instance_type = "t2.samll"
asg_desired_capacity = 2
additional_security_group_ids = [aws_security_group.worker_group_mgmt_one.id]
}
]
}
正在初始化模块... 正在为 eks 下载 terraform-aws-modules/eks/aws 17.1.0...
正在初始化后端...
正在初始化提供程序插件...
合作伙伴和社区提供商由其开发者签署。 如果您想了解有关提供商签名的更多信息,可以在此处阅读: https://www.terraform.io/docs/cli/plugins/signing.html
错误:无法查询可用的提供程序包 无法检索提供者 hashicorp/eks 的可用版本列表:提供者注册表 registry.terraform.io 没有名为 registry.terraform.io/hashicorp/eks 的提供者
所有模块都应该指定他们的 required_providers 以便外部消费者在使用模块时可以获得正确的提供者。要查看当前依赖于 hashicorp/eks 的模块,请运行以下命令:terraform providers
Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/kubernetes] >= 2.0.1
├── provider[registry.terraform.io/hashicorp/aws] 3.43.0
├── provider[registry.terraform.io/hashicorp/random] 3.0.0
├── provider[registry.terraform.io/hashicorp/local] 2.0.0
├── provider[registry.terraform.io/hashicorp/eks]
├── provider[registry.terraform.io/hashicorp/null] 3.0.0
├── provider[registry.terraform.io/hashicorp/template] 2.2.0
└── module.eks
├── provider[registry.terraform.io/hashicorp/aws] >= 3.40.0
├── provider[registry.terraform.io/hashicorp/local] >= 1.4.0
├── provider[registry.terraform.io/hashicorp/kubernetes] >= 1.11.1
├── provider[registry.terraform.io/terraform-aws-modules/http] >= 2.4.1
├── module.fargate
│ └── provider[registry.terraform.io/hashicorp/aws] >= 3.40.0
└── module.node_groups
├── provider[registry.terraform.io/hashicorp/aws] >= 3.43.0
└── provider[registry.terraform.io/hashicorp/cloudinit]
这是我的版本文件
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.43.0"
}
random = {
source = "hashicorp/random"
version = "3.0.0"
}
local = {
source = "hashicorp/local"
version = "2.0.0"
}
null = {
source = "hashicorp/null"
version = "3.0.0"
}
template = {
source = "hashicorp/template"
version = "2.2.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.0.1"
}
}
required_version = ">= 1.0"
}