在 NodeJS 中访问 AWS SSM 参数 [英] Accessing AWS SSM Parameters in NodeJS
本文介绍了在 NodeJS 中访问 AWS SSM 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在我的 nodejs 项目中获取 ssm 参数,我是 IAM 凭证,并在我的弹性 beanstalk 实例中编写了一个测试并且工作正常.问题出在项目内部.任何想法为什么?
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
});
推荐答案
我发现,和这个一样 https://github.com/localstack/localstack/issues/1107
需要在SSM构造函数中传递区域
need to pass the region in the SSM constructor
var ssm = new AWS.SSM({region: 'us-east-1'});
好像是个bug
tks
这篇关于在 NodeJS 中访问 AWS SSM 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文