Last active
December 4, 2024 18:11
-
-
Save cbschuld/938190f81d00934f7a158ff223fb5e02 to your computer and use it in GitHub Desktop.
Obtain values from the AWS Parameter store with Typescript/node
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
import { SSM } from "aws-sdk"; | |
const getParameterWorker = async (name:string, decrypt:boolean) : Promise<string> => { | |
const ssm = new SSM(); | |
const result = await ssm | |
.getParameter({ Name: name, WithDecryption: decrypt }) | |
.promise(); | |
return result.Parameter.Value; | |
} | |
export const getParameter = async (name:string) : Promise<string> => { | |
return getParameterWorker(name,false); | |
} | |
export const getEncryptedParameter = async (name:string) : Promise<string> => { | |
return getParameterWorker(name,true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works like a charm! Only in my case I decided to modify it a bit, because my use case is I'm retrieving an SSM parameter value in my
cdk
script, so in my stack I actually need to create the SSM with the region info likenew SSM({ region: this.region })
. So I updated it slightly to pass in the SSM client to the function instead as in this example.