terraform-aws-modules / terraform-aws-rds

Terraform module to create AWS RDS resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/rds/aws
Apache License 2.0
886 stars 1.34k forks source link

How to retrieve master user secret in same module? #576

Closed larskinder closed 5 days ago

larskinder commented 5 days ago

Hi,

I am currently trying to setup a PostgreSQL database and need to install extensions for it. There is a separate module for it with its own provider, that requires certain DB information, like username and password.

Thing is, when I try to leverage the db_instance_master_user_secret_arn for this, I get an exception.

"arn": one of `arn,name` must be specified

What I tried to do is read the secret using a Secrets Manager data source that depends on the rds module.

I am otherwise not certain, how to do it (should I use a local-exec for this?).

The code I used

data "aws_secretsmanager_secret" "secrets" {
  arn        = module.rds.db_instance_master_user_secret_arn
  depends_on = [module.rds]
}

data "aws_secretsmanager_secret_version" "current" {
  secret_id  = data.aws_secretsmanager_secret.secrets.id
  depends_on = [module.rds]
}
larskinder commented 5 days ago

Was a mistake on my end in a validation