我正在使用如上所述启用 docker 的 dynamoDB local 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
最佳答案
确保您还将 -sharedDb 传递给 docker 镜像。
如果 -sharedDb 不存在,则将使用 dynamodb-local
访问键+区域作为分隔表的命名空间
(就好像它们位于不同的 aws 帐户下)
关于node.js - dynamodb 本地 shell 不使用 docker 镜像列出表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54718308/