AWS Lambda Layer and SSM Parameter Store for multiple functions

Lambda → Systems Manager Parameter Store

A Lambda Layer and the SSM Parameter Store to centrally manage configuration values that can be used by multiple Lambda functions.

The SSM Parameter Store is used to store configuration values, each with a specific parameter path or hierachy (eg: /Config/{Parameter-Name}). The Lambda Layer uses the API command 'GetParametersByPathCommand' to retrieve all of the configuration values that match the parameter path. The Lambda Layer code runs once during the intial Lambda function invocation and stores the configuration values in an object named 'config'. The object is stored in the execution environment's memory and is available for subsequent function invocations. The 'config' object is refreshed whenever a new cold-start of the Lambda function occurs.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Launch Stack

Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-layer-ssm-parameters

Deploy

sam buildsam deploy --guided --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND


Testing

From a web browser, navigate to the Url of the Lambda function to return all of the configuration values.
Update the parameters in the 'parameters/template.yml' if you want to change the configuration values. The value of a parameter can be a simple alpha-numeric string or a JSON string. Then use `sam build` and `sam deploy` to update the stack.

Cleanup

Delete the stack: aws cloudformation delete-stack --stack-name STACK_NAME.

Created by:

Greg Davis

Greg Davis

I am a Principal Solutions Architect, Serverless Developer, Database Engineer, and Data Integration Architect. I specialize in architecting and developing Serverless, event-driven solutions.

Follow on LinkedIn