Simplifying AWS SSM parameter retrieval with the Serverless SSM fetch plugin

Daxay Makwana
2 min readFeb 7, 2023

--

Serverless Framework with AWS SSM Diagram

AWS Systems Manager (SSM) is a powerful service that allows you to manage configuration data for your applications. You can store configuration data as key-value pairs in SSM, and then retrieve it at runtime. However, retrieving SSM parameters in a Serverless environment can be cumbersome and requires writing boilerplate code.

Enter the Serverless SSM fetch plugin, which simplifies the process of retrieving SSM parameters in a Serverless environment. This plugin allows you to retrieve SSM parameters as environment variables, making it easy to access configuration data in your Serverless functions.

In this blog, we will demonstrate how to use the Serverless SSM fetch plugin in a Serverless application.

Step 1: Install the Serverless SSM fetch plugin

To use the Serverless SSM fetch plugin, you first need to install it. To do this, run the following command:

npm install serverless-ssm-fetch --save-dev

Step 2: Add the plugin to your Serverless configuration file

Once you have installed the Serverless SSM fetch plugin, you need to add it to your Serverless configuration file (serverless.yml). To do this, add the following to your plugins section:

plugins:
- serverless-ssm-fetch

Step 3: Add SSM parameters to your Serverless configuration file

Next, you need to add the SSM parameters you want to retrieve as environment variables to your Serverless configuration file. To do this, add the following to your environment section:

environment:
SSM_PARAM_1: ${ssm:/path/to/param1}
SSM_PARAM_2: ${ssm:/path/to/param2}

Step 4: Deploy your Serverless application

Finally, you can access the SSM parameters in your Serverless functions as environment variables. To do this, simply retrieve the values from process.env, like this:

const param1 = process.env.SSM_PARAM_1;
const param2 = process.env.SSM_PARAM_2;

The Serverless SSM fetch plugin makes it easy to retrieve SSM parameters in a Serverless environment. With just a few lines of configuration, you can access SSM parameters as environment variables in your Serverless functions, simplifying the process of managing configuration data. Give it a try in your next Serverless project and see how it can help simplify your development workflow!

--

--

Daxay Makwana
0 Followers

Software Engineer passionate about Backend Engineering. Checkout my Upwork Profile: https://www.upwork.com/freelancers/daxay