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.
ResourceNotFoundException: Cannot do operations on a non-existent tableCommon 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
- Call
CreateTablein a setup step. - Wait until the table status is ACTIVE.
- Then run the tests that read or write it.
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_REQUESTPersist data or create tables per process
Use a shared data directory, or recreate tables in the same process that runs the tests.
aws dynamodb wait table-exists --endpoint-url http://127.0.0.1:8000 \
--region us-east-1 --table-name itemsHow 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.