Created
February 3, 2020 01:30
-
-
Save igorjs/d0d478f34740937c84d8e37ba5f3d3c4 to your computer and use it in GitHub Desktop.
How to get and AWS SSM parameter using SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const AWS = require('aws-sdk'); | |
| const ssm = new AWS.SSM(); | |
| const getParameterFromSystemManager = async (key, isEncrypted = true) => { | |
| // Fetches a parameter from SSM parameter store. | |
| // Requires a policy for SSM:GetParameter on the parameter being read. | |
| const params = { | |
| Name: key, | |
| WithDecryption: isEncrypted // "true" if is a SecureString, otherwise must be "false" | |
| }; | |
| try { | |
| return ssm.getParameter(params).promise(); | |
| } catch (err) { | |
| throw new Error('Failed to get parameter from AWS', err.stack); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment