Retrieving AWS SSM Parameters with Node

Alexandru Bereghici

Alexandru Bereghici / May 03, 2022

1 min read2602 views

AWS logo

SSM (Systems Manager) is a service provided by AWS that allows you to securely store and retrieve data for your application (amongst other things). This can be environment based connection urls, authentication credentials, or properties you’d like to change without needing a re-deploy of your application.

In SSM you can store strings, list of strings and encrypted strings. Also, you can store as JSON and later serialize it to a javascript object.

import SSM from 'aws-sdk/clients/ssm'

const ssm = new SSM()

export async function loadParameter(parameterName: string) {
  try {
    const {Parameter} = await ssm
      .getParameter({
        Name: `/your/namespace/${parameterName}`,
        WithDecryption: true,
      })
      .promise()

    return Parameter?.Value ?? null
  } catch (e) {
    console.error(e)
    return null
  }
}

Discussion

You must be logged in to post a comment

Your information is only used to display your name and reply by email.