Lesson 16 of 30
'Where does the database password actually live?' has a wrong answer (an environment variable, a committed .env file) and two AWS-native right answers — knowing which right answer to reach for is the actual skill.
10 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A team needs an RDS database password to rotate automatically on a schedule without anyone manually updating it. Which service is purpose-built for that?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
A secret — a database password, an API key, a third-party token — has to live somewhere a running application can fetch it, without ever sitting in source control or a plaintext environment variable that anyone with deploy access (or a misconfigured log line) can read. AWS offers two purpose-built places for this:
SecureString tier, encrypted secrets) for free at the standard tier, simpler to use, but with no built-in rotation mechanism of its own.Both solve the same root problem: an application asks for a secret by name at runtime and gets the current value back, instead of the value being baked into code, a config file, or a container image where it's effectively permanent and exposed to anyone who can read that artifact.
{
"Effect": "Allow",
"Action": ["secretsmanager:GetSecretValue"],
"Resource": "arn:aws:secretsmanager:us-east-1:123456789012:secret:prod/db/password-AbC123"
}
This is the same least-privilege shape from this track's IAM lesson, applied to secrets specifically: the Lambda's execution role can read exactly this one secret, by its exact ARN — not secretsmanager:*, which would let it read every secret in the account, including ones that belong to entirely unrelated services. Scoping the resource this tightly means a bug or compromise in this function's code can leak at most one credential, not the account's entire secret inventory.
SecureString tier is genuinely encrypted, not just "less visible." It's a real, valid choice for secrets on a budget or without rotation needs — the free tier isn't a lesser toy version, it's a legitimate tradeoff (no built-in rotation) against Secrets Manager's cost.secretsmanager:* or a wildcard resource is the same anti-pattern here as anywhere else in IAM. Scoping to the exact secret ARN a function actually needs is what makes "least privilege" true in practice rather than a policy that merely gestures at it."Where would you store a database password for a Lambda function, and how would you scope access to it?" tests the same instinct as any IAM question — reaching for a purpose-built, access-controlled secret store scoped to exactly what's needed, rather than an environment variable treated as good enough because it isn't literally committed to git.