gamechanger17
gamechanger17

Reputation: 4629

Getting error ever since I updated Terraform module

I updated my Terraform version and the eks module. Now I am getting a-lot of errors while running the terraform script (which was running fine previously). Some of them I fixed.

    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.

I believe they have removed the map_accounts_count and map_roles_count variables.

Documentation is not that clear. I even checked on the release notes.

below is my 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"
}

Upvotes: 0

Views: 3086

Answers (1)

Andy Shinn
Andy Shinn

Reputation: 28553

Based on https://github.com/terraform-aws-modules/terraform-aws-eks/blob/v6.0.2/variables.tf#L63-L71 and the error you need to update:

  • group to groups
  • role_arn to rolearn

In addition to that you need to update maps to use assignment with = like the docs suggest at https://www.terraform.io/docs/providers/terraform/d/remote_state.html. Your remote state config (and possibly other maps) need to look like:

map = {
  data = "string"
}

Instead of

map {
  data = "string"
}

Upvotes: 3

Related Questions