英文:
Create DynamoDB tables locally from SAM Template yaml file
问题
你可以使用相同的 template.yaml
文件以 AWS::Serverless-2016-10-31
定义,通过 SAM/Cloud Formation 在本地创建 DynamoDB 表格吗?
DynamoDB 在本地运行时,可以使用以下命令启动:docker run -p 8000:8000 amazon/dynamodb-local
,但是目前没有任何表格。
英文:
How can I create tables a Dynamo DB locally using the same template.yaml
file with AWS::Serverless-2016-10-31
definition for SAM/Cloud Formation that I intent to use for production?
DynamoDB is running locally using docker run -p 8000:8000 amazon/dynamodb-local
but has no tables.
答案1
得分: 1
通过安装一个用于解析YAML的CLI解析器,例如yq,它类似于流行的jq
,你可以运行类似这样的Linux命令来配置本地DynamoDB表。这需要你的DynamoDB在本地开发时运行在标准端口8000上:
aws dynamodb create-table --cli-input-yaml "`cat template.yaml | yq .Resources.[MY TABLE NAME].Properties`" --no-cli-pager --endpoint-url http://localhost:8000
使用以下命令验证创建:
aws dynamodb list-tables --endpoint-url http://localhost:8000
英文:
By installing a CLI parser for yaml, example yq that reassembles the popular jq
, you can run a linux command like this to configure your local Dynamo DB tables. This expects your DynamoDB to run on the standard port 8000 for local development:
aws dynamodb create-table --cli-input-yaml "`cat template.yaml | yq .Resources.[MY TABLE NAME].Properties`" --no-cli-pager --endpoint-url http://localhost:8000
Verify the creation using
aws dynamodb list-tables --endpoint-url http://localhost:8000
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论