r/devops • • Sep 10 '26

Architecture How do you provision RDS & DocumentDB users cleanly? Dual Terraform + Pulumi setup feels redundant.

Hi everyone, looking for a sanity check and some advice on DB user management.

Context & Current Setup:
Team: ~10 developers.
Infra: Everything is provisioned with Terraform.

The Catch: Pulumi is used exclusively to connect through a bastion host to create users in RDS (Postgres) and DocumentDB (MongoDB-compatible).

Current Task & Constraints:
I need to integrate AWS Secrets Manager to store and distribute DB passwords so developers can retrieve them securely via IAM policies.

Constraint: IAM DB Authentication is off the table per my mentor's requirement—we must use Secrets Manager or an external password manager.

The Issue:
Maintaining two state stores (Terraform + Pulumi) just to manage database users feels redundant and adds unnecessary friction. I'd love to pitch an alternative that lets us drop Pulumi completely.

Questions:
1. How do you handle RDS / DocumentDB user and credential management in your projects?
2. What is the cleanest pattern to handle this without running dual IaC tools?

Open to any feedback or critique!

15 Upvotes

35 comments sorted by

View all comments

1

u/jbirdkerr Cat Herder Sep 10 '26

I've previously built a Lambda that will create SQL users based on a "username" input. The password would be a random string generated by terraform in a for_each loop run against an arbitrary list of usernames and placed in SSM Parameter Store. The function accepts the username as an env variable and does an SSM lookup for the passwords it needs to make the new account.

Terraform has a resource that manages an individual parameterized execution of a Lambda function. You run a for_each loop against the list of users creating an execution of the Lambda for each user it needs to create. Just need to ensure the SSM parameter for a given username is a requirement for the Lambda execution to be created (otherwise you don't have a password). Final step is to have the creds shipped to the user in a way that makes sense for your team.

1

u/Witty_Philosopher284 Sep 11 '26

Thanks! My main concern with invoking Lambda inside TF is that it leaves passwords in ⁠tfstate⁠ and doesn't handle ⁠destroy⁠ cleanups.

1

u/jbirdkerr Cat Herder Sep 11 '26

Ah yea that's fair. I haven't done this, but maybe have a second Lambda that creates your random password for you? Then the Lambda for your database user creation could just reference the parameter path based on whatever convention you set up (e.g. /<env>/<db-name>/<user>). Could still use the for_each on your list of users; just need to make sure your dependency statements are set up correctly.