Reputation: 1097
I have a list of subnets as list in the vars file, which I want to read a list inside the AWS resource.
variables.tf
variable "alb_subnets" {
type = list(string)
}
terraform.tfvars
subnets = ["subnet-a","subnet-b"]
main.tf
resource "<resource_name>" "test" {
name = var.Name
security_groups = ["${join(",",var.subnets)}"]
}
Error: ValidationError: subnet 'subnet-a,subnet-b' is not valid
status code: 400, request id: dc4be07e-e353-4821-8bde-3d9849584bef
what is the right way to read the list as list inside the AWS resource.
Upvotes: 1
Views: 209
Reputation: 238071
Normally you would just do:
security_groups = var.subnets
However, it seems to me that you are trying to assign subnets as security groups. Even if you fix the syntax, this will not work. For security_groups
you need security groups, not subnets.
Upvotes: 1