Search code examples
amazon-web-servicesterraformterraform-provider-aws

The given value is not suitable for child module variable "aws_auth_user_map" : list of object required


I am trying to load values to below terraform variable but I am getting The given value is not suitable for child module variable The given value is not suitable for child module variable "aws_auth_user_map" defined at modules/cluster/variables.tf:139,1-29: list of object required.

variable "aws_auth_user_map" {
  type = list(object({
    userarn  = string
    username = string
    groups   = list(string)
  }))
  default     = []
  description = "A list of mappings from aws user arns to kubernetes users, and their groups"
}

and this is how I am adding default values.

{userarn="arn:aws:iam::XXXXXX:user/pXXl.brXXd", username="XX.XX", groups=["admin", "dev"]}

Not sure what I am doing wrong here


Solution

  • The default value should be a list:

    variable "aws_auth_user_map" {
      type = list(object({
        userarn  = string
        username = string
        groups   = list(string)
      }))
      default     = [{userarn="arn:aws:iam::XXXXXX:user/pXXl.brXXd", username="XX.XX", groups=["admin", "dev"]}]
      description = "A list of mappings from aws user arns to kubernetes users, and their groups"
    }