0

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.

Andreas Lundgren
  • 12,043
  • 3
  • 22
  • 44

1 Answers1

1

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
Andreas Lundgren
  • 12,043
  • 3
  • 22
  • 44