Skill 2.2.7
Use secret management services to secure sensitive data.
Key Concepts
Secrets Manager stores secrets encrypted with KMS, controls access with IAM and resource policies, logs access in CloudTrail and can rotate secrets automatically using a rotation Lambda function, with managed rotation for RDS, Aurora, Redshift and DocumentDB. Applications call GetSecretValue, ideally through a caching client, instead of embedding credentials.
Parameter Store holds configuration and SecureString values in a hierarchy, with a free standard tier but no built-in rotation. CloudFormation can reference both with dynamic references, such as {{resolve:secretsmanager:MySecret:SecretString:password}}, and ECS can inject them into containers as environment variables.
Lambda always encrypts environment variables at rest with a KMS key, AWS managed by default or a customer managed key you choose. For stronger protection you can enable encryption helpers, which encrypt values client-side in the console so they appear as ciphertext in the configuration; your code must then call kms:Decrypt at runtime, and the execution role needs that permission.
The preferred approach is often not to store the secret in an environment variable at all, but to store its name there and fetch the value from Secrets Manager or Parameter Store at startup, caching it, for example with the Parameters and Secrets Lambda extension.