Sub topic 13
Reading Secrets Manager secrets through Parameter Store
This chapter assumes you can create parameters and secrets, and that you know the GetParameter and GetSecretValue calls. It covers a bridge between the two services. You can read a Secrets Manager secret through the Parameter Store API.
Why use the bridge
Some tools only know how to call Parameter Store. Examples are older scripts, agents, and code that loads everything through ssm:GetParameter. The bridge lets that code read a secret without adding a second client library. It also lets you keep one retrieval code path while some values move to Secrets Manager for rotation.
How it works
Any name that starts with the reserved prefix /aws/reference/secretsmanager/ is treated as a pointer. The rest of the name is the secret's name or ARN. Parameter Store passes the request to Secrets Manager and returns the result in the usual parameter response format.
aws ssm get-parameter \
--name /aws/reference/secretsmanager/myapp/prod/db \
--with-decryptionThe response has Type set to SecureString, and Value holds the secret string. For the JSON secret from earlier chapters, Value is the whole JSON document, which your code still has to parse.
The same call works from an SDK.
import json
import boto3
ssm = boto3.client("ssm")
response = ssm.get_parameter(
Name="/aws/reference/secretsmanager/myapp/prod/db",
WithDecryption=True,
)
creds = json.loads(response["Parameter"]["Value"])
print(creds["username"])Permissions
The caller needs access on both sides. The identity policy must allow ssm:GetParameter on the reference path, and it must allow secretsmanager:GetSecretValue on the secret. If the secret uses a customer managed key, it also needs kms:Decrypt.
{
"Effect": "Allow",
"Action": "ssm:GetParameter",
"Resource": "arn:aws:ssm:us-east-1:111122223333:parameter/aws/reference/secretsmanager/myapp/prod/db"
}Pair this statement with the GetSecretValue and kms:Decrypt statements from the IAM chapter. A policy that grants only ssm:GetParameter on parameter/myapp/prod/* does not cover the reference path.
Limits and common errors
- The secret stays in Secrets Manager. No parameter is created, so it does not appear in the Parameter Store console, and you cannot edit it through
put-parameter. - Request decryption with
--with-decryptionorWithDecryption=True. - Bulk reads such as
get-parameters-by-pathdo not enumerate secrets. Name each secret explicitly. - An
AccessDeniedExceptionusually means one of the three permissions is missing. Check the Secrets Manager and KMS statements before the SSM one. - Rotation still happens in Secrets Manager. Each read returns the current value, so cache it with a short lifetime.
Exercise
A Lambda function's role allows ssm:GetParameter on parameter/myapp/prod/* and secretsmanager:GetSecretValue on the secret. A call to /aws/reference/secretsmanager/myapp/prod/db fails with AccessDenied. What is the likely cause?
Show answer
The role has no ssm:GetParameter permission on the reference path parameter/aws/reference/secretsmanager/myapp/prod/db. The /myapp/prod/* resource does not match it. The role may also lack kms:Decrypt if the secret uses a customer managed key.