Stop 13 · Infrastructure as Code & CI/CDTopics · 9/9

AWS Secrets Manager & Parameter Store

Part of the AWS Roadmap

In short

A database password committed to GitHub can be found by bots within minutes. Secrets Manager and Parameter Store keep passwords and config out of your code, encrypted and controlled by IAM.

Secrets Manager stores secrets such as database passwords and API keys with built-in rotation support for some services. Systems Manager Parameter Store stores configuration values and secure strings, and its standard parameters cost nothing extra. Both keep secrets out of code.

The jaadu pins a simple note to a cork board in an office, while behind a glass door a row of steel bank lockers sits with one small locker glowing.

Think of it like this

The bank locker and the notice board

In a family business in Ahmedabad, the shop's opening hours and price list go on the office notice board, while the safe combination sits in a bank locker that only two people can open, and the bank can change the combination on a schedule. Parameter Store is the notice board, which can also hold sealed envelopes. Secrets Manager is the bank locker with automatic combination changes.

Watch it happen

Secrets Manager vs Parameter Store

Secrets Manager

  • Built for secrets: passwords, API keys
  • Managed rotation, including for RDS
  • Cross-account sharing and replication
  • Charged per secret per month

Parameter Store

  • Config values and SecureString secrets
  • Hierarchies like /shop/prod/db_host
  • Standard parameters at no extra cost
  • No built-in rotation

Database credentials that should rotate: Secrets Manager. Feature flags, URLs and other config, plus simple secrets you rotate yourself: Parameter Store.

The big ideas

What you need to know

Encrypted with KMS

Secrets and SecureString parameters are encrypted with KMS keys. Reading them needs both the read permission and kms:Decrypt.

Rotation

Secrets Manager can rotate RDS, Aurora and other credentials on a schedule, so a leaked password stops working.

Paths for config

Name parameters by app and environment, such as /shop/prod/api_url, and grant access by path prefix.

Native integrations

ECS, Lambda, CodeBuild and CloudFormation can read both services directly, so values never touch your repo.

See it in code

Walk through the code

bash
1# A secret in Secrets Manager2aws secretsmanager create-secret \3  --name shop/prod/razorpay \4  --secret-string '{"key_id":"rzp_live_xxx","key_secret":"REPLACE_ME"}'5 6aws secretsmanager get-secret-value \7  --secret-id shop/prod/razorpay \8  --query SecretString --output text9 10# Config and a SecureString in Parameter Store11aws ssm put-parameter --name /shop/prod/api_url \12  --type String --value "https://api.priyabakes.in"13aws ssm put-parameter --name /shop/prod/smtp_password \14  --type SecureString --value "REPLACE_ME"15 16aws ssm get-parameters-by-path --path /shop/prod \17  --with-decryption --query "Parameters[].[Name,Value]" --output table

1/5A JSON secret holding two related values for a payment gateway.

AWS CLI v2. In real use, don't type secrets in the shell where they land in history. Use --secret-string file://secret.json or the console.

Save yourself the pain

Common mistakes

Oops

Calling get-secret-value on every request in a busy Lambda.

Do this instead

Cache the value in memory, or use the AWS Parameters and Secrets Lambda Extension, to cut latency and API calls.

Oops

Granting secretsmanager:GetSecretValue on * to every app role.

Do this instead

Limit each role to the secrets it needs by ARN or by name prefix like shop/prod/*.

Your mission

Move secrets out of code

~30 min

Quick check

You need the RDS master password changed automatically every 30 days. Which service fits best?

Go deeper

  1. 1Store a database password in Secrets Manager and read it from a Lambda function.
  2. 2Store app config in Parameter Store and inject it into an ECS task definition.
  3. 3Compare the two on rotation, pricing and typical use.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge