terraform error: Invalid value for module argument

1.3k views Asked by At

I am getting this error in tf plan:

Error: Invalid value for module argument

  on ec2_asg.tf line 13, in module "ec2_asg":
  13:   subnets             = [module.vpc.private_subnets]

The given value is not suitable for child module variable "subnets" defined at
.terraform/modules/ec2_asg/variables.tf:388,1-19: element 0: string required.

This is the variable in the module:

variable "subnets" {
  description = "List of subnets for Application. e.g. ['subnet-8da92df7', 'subnet-9e5dc5f6', 'subnet-497eaf33']"
  type        = list(string)
}

This is in the .tf file:

  ......
  ......
  scaling_max         = var.scaling_max_bi
  subnets             = [module.vpc.private_subnets]
  security_groups     = [aws_security_group.id]

Can someone help me fix this?

1

There are 1 answers

0
Marcin On BEST ANSWER

Based on the comments.

The solution was to change:

subnets             = [module.vpc.private_subnets]

into

subnets             = module.vpc.private_subnets