
Troubleshooting RDS Password Rotation with Secrets Manager
My journey troubleshooting AWS Secrets Manager password rotation for Amazon RDS MySQL, from issues to solutions.

I recently worked on the setup of automatic password rotation for one of my existing Amazon RDS MySQL instances using AWS Secrets Manager.
When I first looked at AWS Secrets Manager password rotation, it seemed like a straightforward task. Store the credentials, enable rotation, and AWS would handle the rest automatically.
That part was true. But the surprises came once I tried it in an existing VPC.
This post is not a step-by-step setup guide. Instead, it is a walk-through of the issues I encountered while implementing password rotation in a real environment, especially around VPC networking and MySQL host-based authentication.
Creating the Secret and Enabling Rotation
I started by creating a new secret in AWS Secrets Manager using the Credentials for RDS database secret type.
Creating the secret itself was straightforward. I entered the database credentials, selected the RDS instance, configured a rotation schedule, and since I didn't have an existing Lambda, I chose the AWS-managed option and let AWS create the rotation Lambda for me.
AWS uses an AWS CloudFormation template to create the rotation Lambda function, execution IAM role, and the required permissions for updating credentials.
One detail that caught my attention was that AWS automatically prefixes the Lambda function name with
SecretsManager- , so provide the name accordingly.AWS allows you to configure the VPC, subnet, security group, etc., for the rotation function in the Lambda configuration. By default, it will be in the same subnet as the RDS instance.
After AWS created the rotation Lambda and IAM role, I triggered a manual rotation to verify everything was working.
Lambda Timeout Inside the VPC
The first rotation attempt failed with a timeout error.
I assumed it was a security group issue or a database connectivity problem since it was a connection timeout. After digging through the Amazon CloudWatch logs, the actual issue became clear.
The Lambda function was attached to a VPC.
Even though the Lambda ENIs were placed inside a public subnet, the function still had no outbound internet connectivity. Lambda functions inside a VPC do not receive public IP addresses, so simply placing them in a public subnet does not automatically provide internet access.
That realization took me a little longer than I would like to admit.
Once I understood the networking issue, the fix was obvious. The rotation Lambda still needed to reach Secrets Manager, so I either had to use a NAT Gateway or create a VPC Interface Endpoint.
Once networking was fixed, the timeout issue disappeared, and password rotation finally completed successfully.
From the AWS console, everything appeared healthy. But...
Rotation Succeeded but the Application Failed Authentication
That's when I ran into another problem.
Password rotation was successful, the rotation timestamp was updated in the Secrets Manager console, CloudWatch had no Lambda errors, and the password in the secret had changed. Everything looked correct, but the application's database authentication failed.
I assumed the application was using stale credentials somewhere. It turned out the old password was still valid from certain hosts.
The problem turned out to be entirely inside MySQL authentication behavior.
It was caused by multiple MySQL users sharing the same username with different host definitions.
I had configurations similar to this:
What I had overlooked was that MySQL treats these as completely separate accounts.
From an application perspective, the username looked identical. But internally, MySQL evaluates authentication using both:
- username
- source host
Even though the password rotation updated one account for one host successfully, connections originating from another host were still validating against a different MySQL user entry that retained the old password.
That's why everything worked when the Lambda tested the credentials, while some application hosts continued to fail authentication.
After looking into it properly, the MySQL behavior actually made sense. The existing user model was not well suited for simple automated rotation.
What I Changed
In my case, I replaced multiple host-specific entries with a subnet-based host pattern because all of the application servers already lived within the same trusted network, and all the servers had almost similar access to the databases.
Something closer to:
Depending on the requirements, another option would be using separate database users for different applications instead of relying heavily on host-based differentiation. It depends on how tightly you want to control database access patterns.
Final Thoughts
I thought this would be a quick security improvment task, but I ended up learning a lot more about Lambda networking and how MySQL authentication actually works.
Setting up password rotation wasn't the difficult part. AWS already makes that relatively simple. Most of my time went into figuring out the pieces around it that could affect the rotation.
- VPC connectivity
- ENI behavior
- IAM permissions
- MySQL account design
In the end, the setup worked well, but it definitely taught me not to trust a green "rotation successful" message too quickly.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article