Kevin Hirst
Kevin Hirst

Reputation: 874

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?

Upvotes: 7

Views: 6710

Answers (4)

Noor
Noor

Reputation: 165

There seems to be a bug in AWS that is not including correct sdk version in certain environments. This can be confirmed by logging the sdk version used.

console.log("AWS-SDK Version: " + require('aws-sdk/package.json').version);

Including the required aws-sdk package solved the problem for us.

Try adding the following in package.json:

    "aws-sdk": "^2.339.0"

Upvotes: 1

Adil Shaikh
Adil Shaikh

Reputation: 51

I have tried both getParameter and getParameters function, and both of them are working fine.

It could be possible that you are getting an error since you are passing "apiVersion: '2014-11-06'" to the SSM constructor.

Do not pass any apiVersion parameter to the function. It should work fine.

Upvotes: 1

Joel He
Joel He

Reputation: 31

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.

Upvotes: 3

Kevin Hirst
Kevin Hirst

Reputation: 874

The answer here is that Amazon must have ditched the getParameter() method in favor of only maintaining one method getParameter(s)(). But they didn't update the documentation. That method seems to work just fine.

Upvotes: 2

Related Questions