Skip to main content

Command Palette

Search for a command to run...

Day - 19 | Secret Management

Published
โ€ข2 min read

AWS Services for Secret Management

1๏ธโƒฃ AWS Secrets Manager (Best for production)

Purpose: Secure storage + automatic rotation

๐Ÿ”น What it stores

  • DB credentials (RDS, Aurora)

  • API keys

  • OAuth tokens

  • Any JSON-based secret

๐Ÿ”น Key features

  • ๐Ÿ” Encrypted using KMS

  • ๐Ÿ”„ Automatic rotation via Lambda

  • ๐Ÿงพ Versioning & auditing

  • ๐Ÿ”‘ Fine-grained IAM access

๐Ÿ”น Example (CLI)

aws secretsmanager create-secret \
  --name prod/db/password \
  --secret-string '{"username":"admin","password":"mypassword"}'

๐Ÿ”น Access from EC2 / Lambda

aws secretsmanager get-secret-value --secret-id prod/db/password

2๏ธโƒฃ AWS Systems Manager Parameter Store

Purpose: Config + secrets (simpler & cheaper)

๐Ÿ”น Types

  • String

  • StringList

  • ๐Ÿ” SecureString (encrypted)

๐Ÿ”น Example

aws ssm put-parameter \
  --name "/prod/db/password" \
  --value "mypassword" \
  --type SecureString

Retrieve:

aws ssm get-parameter \
  --name "/prod/db/password" \
  --with-decryption

๐Ÿ” How applications should access secrets

โœ… Use IAM roles, not credentials

App (EC2 / ECS / Lambda)
   โ†“ (IAM Role)
Secrets Manager / Parameter Store
   โ†“
Decrypted secret at runtime

๐Ÿ” Secrets Manager vs Parameter Store

FeatureSecrets ManagerParameter Store
Encryptionโœ… KMSโœ… KMS
Auto Rotationโœ… YesโŒ No
Cost๐Ÿ’ฐ Paid๐Ÿ†“ Mostly free
Versioningโœ… YesLimited
Best forProduction secretsConfig + basic secrets