自从更新Terraform模块以来出现错误

时间:2019-10-22 11:20:02

标签: terraform terraform-provider-aws

我更新了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"
}

1 个答案:

答案 0 :(得分:3)

基于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"
}