Created
February 3, 2022 19:07
-
-
Save SalvoCozzubo/4502fc9c2c598fd344ba061915760136 to your computer and use it in GitHub Desktop.
Handler
This file contains 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 { SSMClient, GetParameterCommand } = require('@aws-sdk/client-ssm'); | |
const AWSXRay = require('aws-xray-sdk'); | |
// code outside the handler | |
const client = AWSXRay.captureAWSv3Client(new SSMClient({})); | |
let value; | |
module.exports.handler = async () => { | |
// check if values is cached | |
if (!value) { | |
const params = { | |
Name: process.env.SSM_PARAMETER, | |
}; | |
const { Parameter } = await client.send(new GetParameterCommand(params)); | |
value = Parameter.Value; | |
} | |
return value; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment