I am getting the Error: Incorrect attribute value type, when I run terraform plan in version 12.24.
Error: Incorrect attribute value type
on .terraform/modules/app/main.tf line 134, in resource "aws_db_subnet_group" "db_subnet_group":
134: subnet_ids = var.subnets
|----------------
| var.subnets is list of tuple with 1 element
Inappropriate value for attribute "subnet_ids": incorrect set element type:
string required.
Code in tf file:
resource "aws_db_subnet_group" "db_subnet_group" {
count = "${var.create_subnet_group ? 1 : 0}"
name_prefix = "${var.name}-"
description = "Database subnet group for ${var.name}"
subnet_ids = var.subnets
The variables.tf file:
variable "subnets" {
description = "Subnets for RDS Instances"
type = "list"
}
How do I fix this?
The error message says that you have
list of tuple with 1 element
, which would mean that thevar.subnets
is something in the form of:Therefore, to use the inner list (i.e. tuple) you have to do: