main.tf:
count = var.create_security_group ? length(lookup(var.db_configs[0],“additional_sg”)) : 0
config.tf:-
db_configs = [
{
“resource_name” = “qa”
“database_name” = “ind”
“security_group_description” = “SG Created for the qa DB”
“additional_sg” = “”
“allowed_cidrs” = [“10.81.0.0/16”]
“number_of_cidr_blocks” = 1
“instance_type” = “db.r5.large”
“username” = “masterusername”
“password” = “${local.db_pass}”
“deletion_protection” = true
“backup_retention_period” = 7
}]
Error:
var.db_configs is empty list of dynamic
The given key does not identify an element in this collection value.