Lesson 1 of 1 Secrets Manager and Parameter Store

Choosing Between Secrets Manager and Parameter Store

This lesson explains how AWS Secrets Manager and AWS Systems Manager Parameter Store both store secrets and configuration securely, and how they differ in rotation, limits and cost.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose between Secrets Manager and Parameter Store for a secret or configuration value.
  • Describe Parameter Store features such as hierarchies, SecureString parameters and public parameters.
  • Explain why values should be fetched once per execution environment and cached.

Side by side

Secrets Manager and Parameter Store both store values securely, encrypt them with KMS and control access with IAM, and both can be referenced from CloudFormation, ECS task definitions and CodeBuild. They differ in what they are designed for.

Secrets Manager is built for credentials that must change regularly. Its main feature is automatic rotation: on a schedule, a rotation function creates a new password, updates it in the database and stores it in the secret, while applications keep reading the current version. AWS provides ready-made rotation functions for Amazon RDS, Aurora, Redshift and DocumentDB credentials, RDS, Aurora and Redshift can also manage their administrator password in Secrets Manager with managed rotation that needs no function, and a custom Lambda function rotates any other kind of secret. A secret can hold up to 64 KB, can be replicated to other Regions and can have a resource policy that lets another account read it. Each secret has a monthly charge.

Parameter Store, part of Systems Manager, is built for configuration. Values are plain String or StringList parameters, or SecureString parameters encrypted with KMS. Names form a hierarchy, such as /orders/prod/db-url, so an application can read all its settings with one call and IAM policies can grant access by path. Standard parameters, up to 4 KB, cost nothing; advanced parameters allow 8 KB and policies such as expiry dates. There is no built-in rotation. The following table summarises the differences.

Secrets Manager
Built forCredentials
Automatic rotationYes: AWS rotation functions or managed rotation for RDS, Aurora, Redshift and DocumentDB; custom Lambda for others
Value typesSecret strings or binary
SizeUp to 64 KB
CostPer secret per month, plus API calls
ExtrasCross-Region replication
Parameter Store
Built forConfiguration (and some secrets)
Automatic rotationNo
Value typesString, StringList, KMS-encrypted SecureString
Size4 KB (standard tier), 8 KB (advanced tier)
CostStandard tier free
ExtrasHierarchical paths; parameter policies (advanced); public parameters

Parameter Store features

Parameter Store provides features for organising parameters and obtaining values published by AWS. The following list describes them.

  • Hierarchies: names such as /app/prod/db-url let you fetch a whole environment's configuration by path.
  • Public parameters: AWS publishes values such as the latest Amazon Linux AMI ID, often referenced from CloudFormation and launch templates.
Sort into groups

Secrets Manager or Parameter Store?

Exam skills 2.2.7 · 3.1.4

Choose the service that fits each value.

Log in to try this activity Interactive activities are free with an account.

Reading values from code

Both services integrate with CloudFormation, Lambda, ECS and CodeBuild. Fetch values once per execution environment and cache them rather than calling the API on every request.

import json, boto3

ssm = boto3.client("ssm")
secrets = boto3.client("secretsmanager")

API_URL = ssm.get_parameter(Name="/orders/prod/api-url")["Parameter"]["Value"]
FLAGS = ssm.get_parameters_by_path(Path="/orders/prod/flags/", Recursive=True, WithDecryption=True)["Parameters"]
DB = json.loads(secrets.get_secret_value(SecretId="orders/db")["SecretString"])   # {"username": ..., "password": ...}

In Lambda, the Parameters and Secrets Lambda extension (or the Powertools parameters utility) serves both from a local cache that refreshes on a TTL, so rotated secrets are picked up. Requests use the function's own session token:

curl -s -H "X-Aws-Parameters-Secrets-Token: $AWS_SESSION_TOKEN" \
  "http://localhost:2773/secretsmanager/get?secretId=orders/db"

The following diagram shows a function reading values through a local cache.

Reading configuration and secrets in Lambda. The Parameters and Secrets Lambda extension, or the Powertools parameters utility, keeps a local cache that the handler reads, and refreshes it from Parameter Store and Secrets Manager when its TTL expires, so a rotated secret is picked up without calling the APIs on every request.
Caching keeps API calls, latency and cost low while still picking up rotated secrets.
Scenario questions

Read secrets and parameters

Exam skills 2.2.7 · 1.1.5

Practise reading configuration and secrets efficiently.

Log in to try this activity Interactive activities are free with an account.
Worked example

Storing an application's configuration

An application uses several configuration values with different requirements. The following table identifies the appropriate store for each value and the reason for the choice.

ValueStoreWhy
Database password, rotated every 30 daysSecrets ManagerAutomatic rotation
Third-party API key, rotated by hand yearlyParameter Store SecureString (or Secrets Manager)Encrypted; no rotation needed; cheaper
Feature setting /orders/prod/maxItemsParameter Store StringPlain configuration, free
Feature flag rolled out gradually with rollbackAppConfigDeployment strategies and alarms
Secret shared with another accountSecrets ManagerResource policies

Whichever store is used, the function caches values (for example with the Parameters and Secrets extension) rather than calling the API on every invocation, which avoids throttling and cost.

Check yourself

A database password must rotate automatically every 30 days. Which service should store it?

Show answer

Secrets Manager, which has built-in rotation through a Lambda function, including templates for RDS. Parameter Store SecureString parameters have no built-in rotation.

Exam Tips

Remember for the exam

  • Database credentials that must rotate automatically belong in Secrets Manager.
  • Cheap, hierarchical configuration values belong in Parameter Store.
  • To cache secrets in Lambda with automatic refresh, use the Parameters and Secrets Lambda extension.
  • To use the latest AMI ID in templates, reference a Parameter Store public parameter.