For your agents’ API keys (OpenAI, Anthropic, Stripe, the CRM), I would start with Parameter Store, encrypted parameters and a cache in Lambda. I would keep Secrets Manager for what needs automatic rotation or several regions, because each secret costs $0.40 a month and with several agents and environments that adds up fast.
The problem
Every agent you build brings its own keys: the model’s, the email provider’s, the tool it queries. The easy path is to paste them into the Lambda function’s environment variables, and the easy path has two costs. Anyone allowed to view the function’s configuration reads them in plain text in the console, and changing a key means touching every function that uses it.
AWS offers two services to get them out of there, and the difference matters more for price and limits than for security: both encrypt with KMS, AWS’s encryption key service.
What each one offers
Secrets Manager was built for sensitive credentials. In the words of the AWS Security Blog (October 2025): “Secrets Manager was designed specifically for sensitive credentials such as database passwords”. What it adds:
- Automatic rotation with a Lambda function.
- Replicas of a secret in other regions.
- Sharing a secret with another account through resource policies.
- Encryption that is always on.
Parameter Store, part of Systems Manager, stores key-value pairs. With the SecureString type the value is encrypted with KMS. It does not rotate anything by itself or replicate across regions, and AWS recommends it for configuration and data without those needs.
What it costs
According to the Secrets Manager pricing page, each secret costs $0.40 a month, plus $0.05 per 10,000 API calls. Yan Cui points out that each replica in another region is billed as another secret.
In Parameter Store, standard parameters carry no additional charge, neither to store them nor to read them at standard throughput. Advanced parameters (values up to 8 KB and expiration policies) and the higher throughput mode are paid: AWS’s euro pricing page lists €0.0493 per advanced parameter a month and per 10,000 calls.
An example: 10 keys across 3 environments (development, staging and production) are 30 secrets. In Secrets Manager, $12 a month before any calls. In standard Parameter Store, $0. It is not a fortune, but it grows with every new agent and buys you nothing if you are not going to rotate those keys automatically.
The limit you do need to watch
Parameter Store’s standard throughput is 40 requests per second, shared by GetParameter, GetParameters and GetParametersByPath in the account and region, according to the AWS documentation. If every Lambda invocation reads the key, a traffic spike gets you throttling errors (AWS rejecting calls for exceeding the limit).
There are two ways out: turn on higher throughput (up to 10,000 requests per second for GetParameter, paying per call) or, better, stop reading the key on every invocation.
How to do it in Lambda
- Store the key as an encrypted parameter, with a path that separates environment and agent:
aws ssm put-parameter \
--name /agents/prod/anthropic-api-key \
--type SecureString \
--value "$ANTHROPIC_API_KEY"
-
Add the AWS Parameters and Secrets Lambda Extension layer to the function. It is an official extension that runs a local server on port 2773 and caches values for 300 seconds by default (the
SSM_PARAMETER_STORE_TTLvariable). -
Give the function’s role only what it needs:
{
"Effect": "Allow",
"Action": ["ssm:GetParameter", "kms:Decrypt"],
"Resource": [
"arn:aws:ssm:eu-west-1:<account>:parameter/agents/prod/*",
"arn:aws:kms:eu-west-1:<account>:key/<key-id>"
]
}
- Read the key from your code. In Node:
const name = encodeURIComponent("/agents/prod/anthropic-api-key");
const res = await fetch(
`http://localhost:2773/systemsmanager/parameters/get?name=${name}&withDecryption=true`,
{ headers: { "X-Aws-Parameters-Secrets-Token": process.env.AWS_SESSION_TOKEN } }
);
const { Parameter } = await res.json();
const apiKey = Parameter.Value;
With the cache, 1,000 invocations in five minutes make one call to Parameter Store per execution environment, not 1,000. A warning from the extension’s documentation: with SnapStart, AWS_SESSION_TOKEN may not exist during initialization, so read the token inside the handler with the SDK’s credential provider.
When you change a key, functions can take up to five minutes to see it. For third-party keys, which you change by hand and rarely, that is acceptable.
My take
My rule: Parameter Store for third-party API keys and configuration; Secrets Manager for database passwords I want rotated on their own, or when I need a replica in another region. Mix the two by secret, rather than putting everything in one out of habit.
What I would never do is leave a key in a plain-text environment variable “for now”. That “for now” ends up in production, and a leaked AI model key turns into an invoice.
What neither service solves: if the agent holds the key in memory, it can use it for anything. One key per agent and per environment, each with its own spending limit at the provider, tells you more about who spent what than any encryption.
Sources
- AWS Security Blog: How to choose the right AWS service for managing secrets and configurations
- AWS Secrets Manager pricing
- AWS Systems Manager pricing (in euros)
- Parameter Store throughput
- Using Parameter Store parameters in Lambda functions
- Yan Cui: Why SSM Parameter Store still reigns over Secrets Manager
If you want to see how I build SaaS on AWS with a small team, follow me on LinkedIn.
