non-existent table amazon/dynamodb-local

472 Views Asked by At

I'm working with aws-cli dynamodb-local, in docker-compose I have an entry as:

volumes:
  dynamo-db:
    driver: local

services:
  dynamodb-local:
    container_name: local-db
    image: amazon/dynamodb-local
    restart: always
    command: -jar DynamoDBLocal.jar -sharedDb -dbPath /home/dynamodblocal/
    volumes:
      - dynamo-db:/home/dynamodblocal
    ports:
      - '8000:8000'
    env_file:
      - ...

The error I receive during the application startup is

ResourceNotFoundException: Cannot do operations on a non-existent table
2023-02-06T23:13:33.829569752Z         at Request.extractError (/srv/node_modules/aws-sdk/lib/protocol/json.js:52:27)
2023-02-06T23:13:33.829573169Z         at Request.callListeners (/srv/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
2023-02-06T23:13:33.829576085Z         at Request.emit (/srv/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
2023-02-06T23:13:33.829578835Z         at Request.emit (/srv/node_modules/aws-sdk/lib/request.js:686:14)
2023-02-06T23:13:33.829581502Z         at Request.transition (/srv/node_modules/aws-sdk/lib/request.js:22:10)
2023-02-06T23:13:33.829584252Z         at AcceptorStateMachine.runTo (/srv/node_modules/aws-sdk/lib/state_machine.js:14:12)
2023-02-06T23:13:33.829587169Z         at /srv/node_modules/aws-sdk/lib/state_machine.js:26:10
2023-02-06T23:13:33.829601794Z         at Request.<anonymous> (/srv/node_modules/aws-sdk/lib/request.js:38:9)
2023-02-06T23:13:33.829605460Z         at Request.<anonymous> (/srv/node_modules/aws-sdk/lib/request.js:688:12)
2023-02-06T23:13:33.829608252Z         at Request.callListeners (/srv/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
2023-02-06T23:13:33.829610960Z message: Cannot do operations on a non-existent table
2023-02-06T23:13:33.829613585Z code: ResourceNotFoundException
2023-02-06T23:13:33.829616169Z requestId: 40aaa8a1-575f-45be-b8b1-e64fb28c9cb4
2023-02-06T23:13:33.829618710Z statusCode: 400

I found articles saying that this might be caused when -sharedDb flag is missing, but I do have specific path for this value. The config from the app level is correct, because I change only url, comparing to other environments where everything works properly. Any suggestions or articles explaining this image's behaviour are more than welcome.

If it helps, I'm using node16 & dynamoose.

1

There are 1 best solutions below

0
Leeroy Hannigan On

If you do not use -sharedDb it means that you have a unique environment for every set of access keys provided. So if you spin up multiple environments with different keys, then you will have to create the tables in that environment.

Either set -sharedDb or ensure you use the same access keys for all invocations.

Docs

The AWS SDKs for DynamoDB require that your application configuration specify an access key value and an AWS Region value. Unless you're using the -sharedDb or the -inMemory option, DynamoDB uses these values to name the local database file. These values don't have to be valid AWS values to run locally. However, you might find it convenient to use valid values so that you can run your code in the cloud later by changing the endpoint you're using.