I use terraform-aws-modules/rds/aws as source to a "db" module, that is used by my other database modules as source. Without any code changes to those parts, I’m receiving an error when trying to Plan with Terraform. I’ll give the details below.
I’m running the following module with terraform-aws-modules/rds/aws
module "db" {
source = "terraform-aws-modules/rds/aws"
version = "~> 4.2"
identifier = var.name
allocated_storage = var.storage
db_name = replace(var.name, "-", "")
...other fields
}
but when terraform tries to Plan, I receive this error:
Error: Unsupported attribute
on .terraform/modules/my-db.db/modules/db_instance/outputs.tf line 63, in output "db_instance_name":
63: value = try(aws_db_instance.this[0].name, "")This object has no argument, nested block, or exported attribute named
│ "name".
I assume this has to do with "name" being deprecated in aws_db_instance. But I’m not using aws_db_instance, so my guess is that it is actually being used by terraform-aws-modules/rds/aws. I have already updated versions, but nothing seems to work…
>Solution :
"I assume this has to do with "name" being deprecated in aws_db_instance. But I’m not using aws_db_instance"
That’s not true. The module you are using most certainly is using aws_db_instance.
module "db" { source = "terraform-aws-modules/rds/aws" version = "~> 4.2"I have already updated versions, but nothing seems to work…
You haven’t updated the module. Version 4.2 is several major versions behind. The latest version of that module, as of the time I’m posting this answer, is 6.1.1
You will need to update to a newer version of the Terraform module to fix the error you are seeing.