First foray into AWS's Lambda@Edge and trying to retrieve secrets from AWS Param Store for authentication (following this article) but getting nothing back.
Here's the function that calls the AWS.SSM function:
const fromParameterStore = async(key, withDecryption = false) => {
const { Parameter } = await ssm.getParameter({ Name: key, WithDecryption: withDecryption }).promise();
return Parameter.Value;
};
And here's how it's called from the main body of the Lambda:
exports.handler = async (event, context, callback) => {
const request = event.Records[0].cf.request;
const testValue = fromParameterStore('my-param-key');
console.log("test value = "+testValue);
console.log("test value = "+JSON.stringify(testValue));
...
The output in the log is just this:
testvar = [object Promise]
testvar = {}
How can I cleanly de-reference the Promise in this case to get the actual secret out for use in the rest of the Lambda?
Thanks!