AWS Lambda VPC on Terraform
I think the value of subnet_ids
is like this: "subnet-xxxxx,subnet-yyyyy,subnet-zzzzz"
and it take it as single subnet instead of list. You can fix this problem like this:
vpc_config {
subnet_ids = ["${split(",", var.subnet_ids)}"]
security_group_ids = ["${var.security_group_ids}"]
}
There was a mapping missing to the lambda module. After fixing it this how the plan should have looked like for the VPC configuration:
vpc_config.#: "1"
vpc_config.0.security_group_ids.#: "1"
vpc_config.0.security_group_ids.571116572: "******"
vpc_config.0.subnet_ids.#: "3"
vpc_config.0.subnet_ids.1396457994: "****"
vpc_config.0.subnet_ids.1722519307: "****"
vpc_config.0.subnet_ids.830820656: "****"
vpc_config.0.vpc_id: "<computed>"