View a markdown version of this page

Using the Parameter Store extension in AWS Systems Manager Cloud Extensions - AWS Systems Manager

Using the Parameter Store extension in AWS Systems Manager Cloud Extensions

The extension serves the Systems Manager API of Parameter Store at the endpoint http://localhost:5333/parameterstore. Every request is an HTTP POST to that endpoint in the AWS JSON 1.1 protocol of Systems Manager. The X-Amz-Target header names the operation, such as AmazonSSM.GetParameter, and the body is the JSON input of the operation. The SSM client of an AWS SDK, and the AWS CLI, send these requests for you when you give them the endpoint.

Authentication

Sign each request with Signature Version 4 for the service ssm. Use the extension key of the profile as the credentials: its access key ID and its secret key. The runtime checks the signature. The extension then calls Parameter Store with its own role, not with the extension key. An SDK or the AWS CLI signs the requests when you give it the extension key as its credentials. For curl, use the --aws-sigv4 option.

The runtime rejects a request without a signature, or with a signature that doesn't match, with 400 AccessDeniedException. The cloudextensions-error-reason header holds the reason, such as MISSING_AUTHENTICATION or SIGNATURE_MISMATCH.

Operations

The extension has two read-only operations. They share the same cache entries, so a value that one operation fetches serves the other.

Operation X-Amz-Target Returns Use it when

GetParameter

AmazonSSM.GetParameter

The Parameter Store GetParameter response: {"Parameter": {...}}

You read one parameter.

GetParameters

AmazonSSM.GetParameters

The Parameter Store GetParameters response: {"Parameters": [...], "InvalidParameters": [...]}

You read up to 10 parameters at once.

The extension serves no other operation of Systems Manager. A request for another operation, such as PutParameter or GetParametersByPath, fails with 400 ValidationException and the message No operation matches the request.

GetParameter calls Parameter Store GetParameter only on a cache miss. A cache miss means that the parameter isn't cached yet or that its cached entry is stale. The extension returns a fresh cached entry without calling Parameter Store. The call to Parameter Store can fail for a transient reason, such as throttling. If the cache holds a value for the parameter, the extension then returns the cached value instead, even after its TTL, and treats it as fresh for another TTL.

GetParameters answers from the cache without calling Parameter Store only when every name in the request is fresh in the cache. Otherwise, the extension sends every name in the request, the fresh ones too, to Parameter Store in one GetParameters call. The extension returns the answer of Parameter Store. The call can fail for a transient reason, such as throttling. If every name has a cached value, the extension then returns the cached values instead, even values past their TTL, and treats them as fresh for another TTL. For more information, see How GetParameters uses the cache.

Request parameters

The request parameters are those of Parameter Store, in the JSON body of the request. The extension has no request parameter for the AWS Region. It reads every parameter in the Region of the runtime.

GetParameter takes the following parameters:

Parameter Type Required Default Constraints Description

Name

string

Yes

None

1 to 2,048 characters

The parameter name, such as /my-app/db-host, or its full ARN. You can add a version, such as /my-app/db-host:3, or a label, such as /my-app/db-host:prod.

WithDecryption

boolean

No

false

true or false

Return a SecureString value decrypted. Without this parameter, you get the encrypted value. The role needs kms:Decrypt on the key. The parameter has no effect on String or StringList parameters.

GetParameters takes the following parameters:

Parameter Type Required Default Constraints Description

Names

list of strings

Yes

None

1 to 10 names. Each name has 1 to 2,048 characters.

The parameter names, ARNs, or names with a :version or :label selector. A duplicate name counts toward the limit of 10, and the extension answers it once.

WithDecryption

boolean

No

false

true or false

Return every SecureString value decrypted. The role needs kms:Decrypt on each key.

Response shapes

The status of a successful response is 200 OK, and the Content-Type is application/x-amz-json-1.1. The body is the response of Parameter Store, with its member names and types. For example, ARN is in capital letters, and LastModifiedDate is a number of epoch seconds with milliseconds. An SDK turns LastModifiedDate into the date type of its language.

GetParameter

The following example shows the body of a GetParameter response.

{ "Parameter": { "ARN": "arn:aws:ssm:us-west-2:111122223333:parameter/my-app/db-host", "DataType": "text", "LastModifiedDate": 1795637952.77, "Name": "/my-app/db-host", "Type": "String", "Value": "db.example.com", "Version": 1 } }

The Parameter object has the following members.

Member Type Always present Notes

Name

string

Yes

The name of the parameter.

Value

string

Yes

The value of the parameter. A StringList is the comma-separated string of Parameter Store. A SecureString that you read without WithDecryption is the encrypted value.

Type

string

No

String, StringList, or SecureString

Version

long

No

The version of the parameter.

Selector

string

No

The :version or :label from the request, such as :1.

SourceResult

string

No

For a Secrets Manager reference through /aws/reference/secretsmanager/, the details of the secret, as Parameter Store returns them.

LastModifiedDate

timestamp

No

Epoch seconds with a fraction, such as 1795637952.77.

ARN

string

No

The ARN of the parameter.

DataType

string

No

text or another data type. For example, aws:ec2:image.

If Parameter Store leaves a member out of its response, the extension leaves the member out too.

GetParameters

The body is the GetParameters response of Parameter Store, with nothing added. Both lists are always present.

{ "InvalidParameters": [ "/my-app/does-not-exist" ], "Parameters": [ { "ARN": "arn:aws:ssm:us-west-2:111122223333:parameter/my-app/api-url", "DataType": "text", "LastModifiedDate": 1795637953.606, "Name": "/my-app/api-url", "Type": "String", "Value": "https://api.example.com", "Version": 1 }, { "ARN": "arn:aws:ssm:us-west-2:111122223333:parameter/my-app/db-host", "DataType": "text", "LastModifiedDate": 1795637952.77, "Name": "/my-app/db-host", "Type": "String", "Value": "db.example.com", "Version": 1 } ] }

The response has the following members.

Member Type Notes

Parameters

list of parameters

The parameters that the extension read, sorted by Name. Each parameter has the members of the Parameter object of GetParameter. For a name with a selector, Name is the name without the selector, and Selector holds the selector, such as :1 or :prod.

InvalidParameters

list of strings

The requested names without a value, sorted. These are the names that Parameter Store reports as not valid. For example, a parameter that doesn't exist, a version or label that doesn't exist, or a SecureString whose AWS Key Management Service (AWS KMS) key is disabled.

A name that doesn't exist doesn't fail the request. The extension lists the name in InvalidParameters, and the status is still 200 OK.

AWS CLI examples

These examples read the parameters /my-app/db-host and /my-app/api-url, which are String parameters, and /my-app/db-password, which is a SecureString parameter. Replace them with the names of your own parameters. Run the examples while the runtime serves the extension. Use the extension key of the profile as the credentials of the AWS CLI:

export AWS_ACCESS_KEY_ID=extension-access-key-id export AWS_SECRET_ACCESS_KEY=extension-secret-key export AWS_REGION=us-west-2 E=http://localhost:5333/parameterstore

Then run the following commands:

# One parameter (GetParameter) aws ssm get-parameter --endpoint-url $E --name /my-app/db-host # Only the value aws ssm get-parameter --endpoint-url $E --name /my-app/db-host --query Parameter.Value --output text # Several parameters (GetParameters) aws ssm get-parameters --endpoint-url $E --names /my-app/db-host /my-app/api-url # A SecureString, decrypted aws ssm get-parameter --endpoint-url $E --name /my-app/db-password --with-decryption

For examples with curl, see Examples with curl for the Parameter Store extension in AWS Systems Manager Cloud Extensions. For an example with the AWS SDK for Python (Boto3), see Lambda function example for the Parameter Store extension in AWS Systems Manager Cloud Extensions.