Secrets and sensitive data
DVA-C03 · Lesson 13 of 24 · 1:44:34
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the DVA-C03 exam (AWS Certified Developer – Associate). In this lesson: Secrets Manager rotation and replication, Parameter Store hierarchies and SecureString parameters, the Lambda extension and caching, data minimization, masking in code, and CloudWatch Logs data protection policies. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Passwords in plain sight
A review at AnyCompany Tickets found the database password in an environment variable, and the payment provider's API key in a configuration file. The logs were no better, with full email addresses and phone numbers of fans. This lesson covers Secrets Manager and its rotation, Parameter Store, secrets in Lambda functions, and the masking of personal data.
Secrets Manager
AWS Secrets Manager stores secrets, like database credentials and API keys, encrypted with a KMS key, and the code fetches them at run time with GetSecretValue. Its main feature is automatic rotation. For many managed secrets, like those of an RDS database, managed rotation needs no code, while other secrets rotate with a Lambda function that updates both the secret and the service. A secret can also be replicated to other Regions, and shared with another account through a resource-based policy.
Parameter Store
Parameter Store, a capability of AWS Systems Manager, keeps configuration values in a hierarchy, like slash tickets, slash prod, slash database host. A parameter is a String, a StringList, or a SecureString, encrypted with KMS, and the code reads a whole branch with GetParametersByPath. The standard tier is free, with values up to four kilobytes, and the advanced tier allows eight kilobytes and parameter policies. AWS recommends Secrets Manager for credentials, because Parameter Store has no built-in rotation.
Secrets in Lambda
A function should not call Secrets Manager on every invocation, which adds latency and cost. So fetch the secret outside the handler, cache it, and refresh it after a few minutes, so that a rotation still reaches the code. The AWS Parameters and Secrets Lambda Extension, added as a layer, retrieves and caches secrets and parameters for you, without the SDK. And never put secrets in plain environment variables, in the code, or in the logs.
Personal data
Personal data, like names, email addresses, phone numbers, and card numbers, needs extra care. First, collect and keep only what the app needs, and never log it raw: mask it in the code, like showing only the last four digits. CloudWatch Logs adds a safety net: a data protection policy on a log group finds sensitive data with data identifiers, and audits and masks it. The data is masked everywhere it leaves, including Logs Insights, metric filters, and subscription filters. And only users with the logs Unmask permission can see the original values, which keeps unmasking rare and logged.
Where each value goes
So each value has its place. Credentials and API keys go to Secrets Manager, with rotation. Configuration values go to Parameter Store, as plain strings, or as SecureStrings when they must be encrypted. And personal data stays out of the logs, masked in the code, and masked again by a data protection policy.
Recap
Let's recap. Secrets Manager stores credentials encrypted with KMS, and rotates them, with managed rotation or a Lambda function. Parameter Store keeps a hierarchy of strings and SecureStrings, free in the standard tier, without built-in rotation. Functions fetch secrets outside the handler and cache them, or use the Parameters and Secrets extension. Personal data is collected sparingly, and masked in the code before it reaches a log. And data protection policies mask sensitive data in log groups, with the Unmask permission kept for a few people.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
The password of the orders database must change every thirty days, with no one doing it by hand, and the application must always read the current value. What should the developer use?
- Secrets Manager, with automatic rotation
- A SecureString parameter in Parameter Store
- An encrypted environment variable
- A customer managed key in AWS KMS
Show the answer
Secrets Manager, with automatic rotation
Secrets Manager rotates the password on a schedule, and the code reads the current value at run time. “A SecureString parameter in Parameter Store” would encrypt the value, but nothing would rotate it. “An encrypted environment variable” would keep the password in the function's settings, and every change would mean a new deployment. And “A customer managed key in AWS KMS” would encrypt the data, without ever changing the password.
Support engineers can read the email addresses of fans in the log events of the order function. Only the security team should see them, and the code cannot change this week. What should the developer configure?
- A shorter retention period for the log group
- A KMS key to encrypt the log group at rest
- A data protection policy, with logs:Unmask
- A deny on all logs for support engineers
Show the answer
A data protection policy, with logs:Unmask
A data protection policy masks the email addresses in the log group, and only the security team gets the permission to unmask them. “A shorter retention period for the log group” would delete the logs sooner, while the addresses stay visible until then. “A KMS key to encrypt the log group at rest” would encrypt the logs at rest, and support engineers would still read them in clear text. And “A deny on all logs for support engineers” would block the engineers from all logs, not just from the addresses.
The app needs a partner’s endpoint URL and account number, which must be encrypted but never rotate, at the lowest cost, with one value per environment. What should the developer use?
- A secret in Secrets Manager for each environment
- A String parameter in Parameter Store
- Constants in the source code of the app
- SecureString parameters, standard tier
Show the answer
SecureString parameters, standard tier
A SecureString in the standard tier is encrypted with KMS, organized by environment in the hierarchy, and free. “A secret in Secrets Manager for each environment” would encrypt the values, but it would charge for rotation features that these values never need. “A String parameter in Parameter Store” would leave the values in clear text. And “Constants in the source code of the app” would put the values in the code, and in every copy of the repository.