Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS parameter store access in lambda function

I'm trying to access the parameter store in an AWS lambda function. This is my code, pursuant to the documentation here: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SSM.html

var ssm = new AWS.SSM({apiVersion: '2014-11-06'});
var ssm_params1 = {
    Name: 'XXXX', /* required */
    WithDecryption: true
};

ssm.getParameter(ssm_params1, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     clientId = data.value;
});

Upon execution, I get the error:

"TypeError: ssm.getParameter is not a function"

Did amazon change this without changing the docs? Did this function move to another type of object?

like image 364
Kevin Hirst Avatar asked Jul 14 '17 17:07

Kevin Hirst


People also ask

Can you pass parameters to Lambda function?

Short description. To configure a REST API to pass query string parameters to a backend Lambda function, use a Lambda custom integration. To pass query string parameters to an HTTP endpoint, use an HTTP custom integration. Important:Make sure that the input data is supplied as the integration request payload.

How do I access environment variables in Lambda?

Open the Functions page of the Lambda console. Choose a function. Choose Configuration, then choose Environment variables. Under Environment variables, choose Edit.

Can Lambda layer access environment variables?

It retrieves values from Secrets Manager and converts the secret into an environmental variable that can be used by other layers and functions. The Lambda layer uses a wrapper script to fetch information from Secrets Manager and create environmental variables.


1 Answers

Please check and try the latest version of the SDK. It is not the case that Amazon has ditched the getParameter method in favor of only getParameters. The fact is the method is getParameter, together with getParametersByPath, is newly added methods. Old version of SDK would not resolve these methods.

like image 117
Joel He Avatar answered Oct 11 '22 14:10

Joel He