javascript - AWS Dynamodb 配置中缺少凭证,如果使用 AWS_CONFIG_FILE,则设置 AWS_SDK_LOAD_CONFIG=1
问题描述
我正在尝试在dynamodb的表中添加元素,如下例所示,但是当我运行它时,我收到以下错误消息:Missing credentials in the config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
aws.config.update({
region: "eu-west-1",
endpoint: "http://localhost:8080",})
let ddb = new aws.DynamoDB.DocumentClient({
apiVersion: "2012-08-10",
});
let params = {
TableName: "NameOfTheTable",
Item: {
uuid: JSON.stringify(132), // random number for testing
name: JSON.stringify(req.query.mod), //data i'm passing in
},
};
const addMod = ddb.put(params, function (err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data);
}
});
return res.send(addMod);
});
我想可能我错过了accessKeyId
和accessSecretKey
但老实说,我不明白如何设置它们
解决方案
您似乎在查询本地凭据,因为 SDK 会检查它们,这似乎是一个问题。
您可以通过指定任何字符串来解决。试试下面的代码片段。
aws.config.update({
region: "eu-west-1",
endpoint: "http://localhost:8080",
accessKeyId: “xxxxxx”,
secretAccessKey: “xxxxxx”
});
推荐阅读
- c# - 无法访问 WindowsXamlHost 控件的 ItemInvoked 事件处理程序
- webpack - 如何更改 CRA 中的 CSS 模块?
- python - 使用 ElementTree (python) 解析 xml 文件时出错
- apiary.io - Dredd - 如何根据 http 状态码修改测试结果?
- c# - 将线程用于非常小的操作会更好,还是总是首选任务?
- swift - SKEmitterNode如何倒带时间?
- java - 如何从另一个类访问片段类中呈现的 TextView 和进度条
- javascript - 如何防止在java脚本上重新刷新页面?
- go - 包的 `init()` 函数中的无限循环 - 好主意还是坏主意?
- ios - Fastlane 扫描在当前测试会话未完成时启动新的测试会话