自从我更新了地形模块以来出现错误



我更新了我的Terraform版本和eks模块。现在我在运行 terraform 脚本(以前运行良好)时遇到很多错误。其中一些我修复了。

Error: Invalid value for module argument
on eks.tf line 27, in module "eks":
27:   map_roles = [
28:      {
29:       role_arn = "${format("arn:aws:iam::%s:role/admin", var.target_account_id)}"
30:       username = "${format("%s-admin", var.name)}"
31:       group    = ["system:masters"]
32:      },
33:    ]
The given value is not suitable for child module variable "map_roles" defined
at
.terraform/modules/eks/terraform-aws-modules-terraform-aws-eks-1be1a02/variables.tf:63,1-21:
element 0: attributes "groups" and "rolearn" are required.

Error: Unsupported block type
on provider.tf line 30, in data "terraform_remote_state" "state":
30:   config {
Blocks of type "config" are not expected here. Did you mean to define argument
"config"? If so, use the equals sign to assign it a value.

我相信他们已经删除了map_accounts_count和map_roles_count变量。

文档不是那么清楚。我什至检查了发行说明。

以下是我 eks.tf

module "eks" {
source  = "terraform-aws-modules/eks/aws"
version = "6.0.2"
cluster_name = "${var.name}"
subnets      = ["${module.vpc.private_subnets}"]
vpc_id       = "${module.vpc.vpc_id}"
cluster_version = "${var.cluster_version}"
kubeconfig_aws_authenticator_additional_args = ["-r", "arn:aws:iam::${var.target_account_id}:role/terraform"]
worker_groups = [
{
instance_type        = "${var.eks_instance_type}"
asg_desired_capacity = "${var.eks_asg_desired_capacity}"
asg_max_size         = "${var.eks_asg_max_size}"
key_name             = "${var.key_name}"
},
]

map_accounts = ["${var.target_account_id}"]
map_roles = [
{
role_arn = "${format("arn:aws:iam::%s:role/admin", var.target_account_id)}"
username = "${format("%s-admin", var.name)}"
group    = ["system:masters"]
},
]

#map_accounts_count = "1"
#map_roles_count    = "1"
write_kubeconfig      = "false"
write_aws_auth_config = "false"
}
resource "local_file" "kubeconfig" {
content  = "${module.eks.kubeconfig}"
filename = "./.kube_config.yaml"
}

根据 https://github.com/terraform-aws-modules/terraform-aws-eks/blob/v6.0.2/variables.tf#L63-L71 和您需要更新的错误:

  • groupgroups
  • role_arnrolearn

除此之外,您还需要更新地图以将分配与=一起使用,就像文档在 https://www.terraform.io/docs/providers/terraform/d/remote_state.html 中建议的那样。远程状态配置(可能还有其他映射)需要如下所示:

map = {
data = "string"
}

而不是

map {
data = "string"
}

相关内容

  • 没有找到相关文章

最新更新