【发布时间】:2019-07-10 03:02:59
【问题描述】:
我正在使用启用 docker 的本地 dynamoDB,如提到的 here
以下是我的 JS 代码:
AWS.config.update({
region: 'sas',
endpoint: 'http://docker.for.mac.host.internal:8000' //'http://localhost:8000'
});
并在下面创建表函数:
function createTable() {
let params = {
TableName: 'sas',
KeySchema: [{
AttributeName: 'title',
KeyType: 'HASH',
}],
AttributeDefinitions: [{
AttributeName: 'title',
AttributeType: 'S'
}],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
}
};
dynamoDB.createTable(params, function(err, data) {
if (err)
console.log(err); // an error occurred
else
console.log(data);
});
}
我可以使用 cli 看到创建的表 sas :
aws dynamodb list-tables --endpoint-url http://localhost:8000 --region=sas
但未在 中列出该表,并且它始终为空。
http://localhost:8000/shell/
有什么想法吗?
注意: 通过在本地运行 dynamodb jar,我可以使用上面的代码查看我的表格
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
【问题讨论】:
-
对我来说,诀窍是检查我的 .aws\config 文件中的区域并将其设置为与您在 JS 代码中提到的相同 - sas (对我来说,它设置为eu-west-2),也许它可以帮助某人......
标签: node.js amazon-web-services docker amazon-dynamodb dynamo-local