node.js - dynamodb 本地 shell 不使用 docker 镜像列出表

标签 node.js amazon-web-services docker amazon-dynamodb dynamo-local

我正在使用如上所述启用 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/

相关文章:

javascript - Gulp Concat 文件顺序然后任何其他 js 文件

amazon-web-services - 删除 Cloudformation 模板中 "Fn::join"之前的空项

java - 尝试在 docker 容器内设置 eclipse,并通过 Xming 通过 X11 进行访问

Docker:如何重新启动容器内的进程?

javascript - 如何在 Node.js 中创建函数配置变量?

node.js - 使用 NodeJS 的 AWS Lambda 函数中的 AWS-SDK 加载错误

node.js - 无法创建 AWS CloudFormation 堆栈

amazon-web-services - 在 JSON 中,模板格式错误 : Unresolved resource dependencies ~~ in the Resources block of the template

node.js - 错误 "enoent ENOENT: no such file or directory, open '/app/package.json'"docker 引用外部文件夹

javascript - 如何在 Slack App 中将值从 Slack channel 传递到 `Options Load URL`