You must rotate the database password used by 30 services without any downtime. How?
IntermediateScenarioSecurity incidents
Answer
Situation read → If you change the password in one step, every service using the old one fails until it reloads. You need a period where both work.
What I'd do →
- Use the two-user (alternating) pattern:
app_aandapp_bwith identical grants. Services use one while the other is rotated. - Store credentials in Secrets Manager; rotation updates the inactive user, then flips the secret to it.
- Services fetch the secret at runtime and reconnect on auth failure, or External Secrets refreshes the Kubernetes Secret and a reloader restarts pods with a rolling update.
metadata:
annotations:
reloader.stakater.com/auto: "true"
- The old user stays valid until the next rotation, so slow services still connect.
- Better long term: IAM database authentication (RDS) with short-lived tokens, so there's no static password at all.
Why → Overlapping validity is the only way to rotate without a synchronised restart of 30 services.
Interview tip → Name the alternating-users strategy; it's the one AWS's managed rotation uses.
More on Security incidents
An AWS access key for a production IAM user was pushed to a public GitHub repo 20 minutes ago. What do you do in the first 30 minutes?AdvancedYou find pods in your cluster running a crypto miner. What do you do?AdvancedA critical CVE is announced in a library you use. You have 200 images across 40 repos. How do you find and patch everything fast?IntermediateGuardDuty reports an EC2 instance talking to a known command-and-control IP. What do you do?AdvancedYou discover an S3 bucket with customer data has been public for three months. What now?IntermediateAn engineer left the company three weeks ago and you find their access key was used yesterday. How do you respond and fix the process?Beginner