0

I have a simple docker file, which has to create tables in DynamoDB:

FROM amazon/aws-cli AS seed

CMD ["dynamodb", "--endpoint-url", "http://dynamodb:8000", "create-table", "--table-name", "mytable", "--attribute-definitions", "AttributeName=user_id,AttributeType=N", "AttributeName=order_id,AttributeType=N", "--key-schema", "AttributeName=user_id,KeyType=HASH", "AttributeName=order_id,KeyType=RANGE", "--provisioned-throughput", "ReadCapacityUnits=5,WriteCapacityUnits=5", "--region", "eu-west-2"]
CMD ["dynamodb", "list-tables", "--endpoint-url", "http://dynamodb:8000"]

The output of the container is:

Run docker-compose -f my-compose.yaml up --abort-on-container-exit --force-recreate --remove-orphans my-container
Recreating dynamodb ... 
Recreating my-container    ... done
Attaching my-container
my-container          | {
my-container          |     "TableNames": []
my-container          | }
my-container exited with code 0
Aborting on container exit...

As you can see there's no any error from the table creation command, but the table list is empty after the creation. What am I doing wrong? Thanks in advance.

Bulchsu
  • 580
  • 11
  • 33
  • 1
    Not 100% clear to me how DynamoDB Local handles regions but are you missing region eu-west-2 when listing? – jarmod Feb 10 '22 at 15:00
  • 1
    A Docker container only runs one command; if you have multiple `CMD` lines only the last one has an effect. – David Maze Feb 10 '22 at 16:41

0 Answers0