I am able to retrieve data from the AWS SSM Parameter Store locally in NodeJS but am unable to when I move my code to Lambdas.
I've hunted and not found many examples of setting up Lambdas with NodeJS that aren't using the "Serverless" framework.
I know I'm missing something simple. I just don't know what yet.
I've given my lambda's IAM policy these permissions:
"Effect": "Allow",
"Action": [
"ssm:PutParameter",
"ssm:GetParameter"
],
"Resource": [
"arn:aws:ssm:region:account-id:parameter/Name/Of/Parameter"
]
AWS.config.update({region: 'my-region'})
const ssm = new AWS.SSM()
ssm.getParameter({
Name: '/Name/Of/Parameter',
WithDecryption: false
}, (err, data) => {
if (err) {
reject(err);
}
if (data.Parameter !== undefined) {
resolve(data.Parameter.Value);
}
reject(new Error('No Parameter'));
});
Locally data is defined. In my lambda I get the error: "{ TypeError: Cannot read property 'Parameter' of null" meaning 'data' is empty as is err.
Any insight is appreciated.