问题描述
以下代码可在Mac上运行,但会在Ubuntu 20.04 ec2实例上抛出
const { SecretsManager } = require('aws-sdk');
(async () => {
const secrets = new SecretsManager({ apiVersion: '2017-10-17',region: 'us-west-2' });
try {
const { SecretString } = await secrets.getSecretValue({ SecretId: 'some-secret-id' }).promise();
console.log(SecretString);
} catch (error) {
console.error(error);
}
})();
操作系统:Ubuntu 20.04
节点:v12.18.3
工作机:
作业系统:macOS 10.15.6
节点:v12.16.1
它也可以在使用最新的NodeJS 12.x版本的Docker中工作
错误:
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer,TypedArray,DataView,or KeyObject. Received undefined
at prepareSecretKey (internal/crypto/keys.js:304:11)
at new Hmac (internal/crypto/hash.js:113:9)
at Object.createHmac (crypto.js:143:10)
at Object.hmac (/var/app/tst/node_modules/aws-sdk/lib/util.js:423:30)
at Object.getSigningKey (/var/app/tst/node_modules/aws-sdk/lib/signers/v4_credentials.js:62:8)
at V4.signature (/var/app/tst/node_modules/aws-sdk/lib/signers/v4.js:98:36)
at V4.authorization (/var/app/tst/node_modules/aws-sdk/lib/signers/v4.js:93:36)
at V4.addAuthorization (/var/app/tst/node_modules/aws-sdk/lib/signers/v4.js:35:12)
at /var/app/tst/node_modules/aws-sdk/lib/event_listeners.js:242:18
at finish (/var/app/tst/node_modules/aws-sdk/lib/config.js:386:7) {
code: 'ERR_INVALID_ARG_TYPE',retryDelay: 20.307687997107028
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)