Accessing AWS SSM Parameters in NodeJS

Otavio Carvalho picture Otavio Carvalho · Oct 30, 2019 · Viewed 8k times · Source

I'm trying to get the ssm parameter inside my nodejs project, is IAM credentials I and wrote a test in my elastic beanstalk instance and works. The problem is inside the project. Any ideas why?

// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');

AWS.config.update({region: 'us-east-1'});

var ssm = new AWS.SSM();

var options = {
  Name: '/test/test', /* required */
  WithDecryption: false
};
var parameterPromise =  ssm.getParameter(options).promise();

parameterPromise.then(function(data, err) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Answer

Otavio Carvalho picture Otavio Carvalho · Nov 1, 2019

I discovered, the same of this https://github.com/localstack/localstack/issues/1107

need to pass the region in the SSM constructor

var ssm = new AWS.SSM({region: 'us-east-1'});

seems to be a bug

tks