Skip to content
Latchkey

DynamoDB Local "Cannot do operations on a non-existent table" in CI

DynamoDB Local starts with no tables and does not persist by default. A query before the create-table step fails with "ResourceNotFoundException: Cannot do operations on a non-existent table", which in CI means setup did not run or ran against a different instance.

What this error means

An SDK call returns "ResourceNotFoundException: Cannot do operations on a non-existent table" for a table the test expects to exist.

aws-sdk
ResourceNotFoundException: Cannot do operations on a non-existent table

Common causes

The create-table step did not run first

The test performed a read or write before any CreateTable call populated the schema.

In-memory mode lost tables on restart

DynamoDB Local in -inMemory mode keeps nothing across restarts, so tables created in an earlier process are gone.

How to fix it

Create the table before using it

  1. Call CreateTable in a setup step.
  2. Wait until the table status is ACTIVE.
  3. Then run the tests that read or write it.
Terminal
aws dynamodb create-table --endpoint-url http://127.0.0.1:8000 --region us-east-1 \
  --table-name items --attribute-definitions AttributeName=id,AttributeType=S \
  --key-schema AttributeName=id,KeyType=HASH --billing-mode PAY_PER_REQUEST

Persist data or create tables per process

Use a shared data directory, or recreate tables in the same process that runs the tests.

Terminal
aws dynamodb wait table-exists --endpoint-url http://127.0.0.1:8000 \
  --region us-east-1 --table-name items

How to prevent it

  • Create tables and wait for ACTIVE before tests.
  • Recreate schema in the same process when using in-memory mode.
  • Use a fixed region and endpoint everywhere.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →