我已使用AWS Client Profile Credential
将aws configure
存储在AWS CLI中。我想在我的节点程序中使用这些凭据。我使用了SharedIniFileCredentials
方法来检索凭证,它仅返回accessKeyId
和其他一些数据,但我也需要Secretkey
和Region
。
代码
var credentials = new AWS.SharedIniFileCredentials({
profile: 'default'
});
AWS.config.credentials = credentials;
console.log(credentials);
const SSM = require('aws-sdk/clients/ssm');
const ssm = new SSM()
const query = {
"Names": ["XXXXX" + XXX],
"WithDecryption": true
}
ssm.getParameters(query, (err, data) => {
if (err) {
console.log('error');
} else {
console.log('sucess');
data;
}
})
输出
SharedIniFileCredentials {
expired: false,
expireTime: null,
refreshCallbacks: [],
accessKeyId: 'XXXXXXXXXXXX', // I have loaded Access key, Secret Key and Region in Profile Config. But I am get only accessKeyID
sessionToken: undefined,
filename: undefined,
profile: 'default',
disableAssumeRole: false,
preferStaticCredentials: false,
tokenCodeFn: null,
httpOptions: null }