DynamoDB ResourceInUseException

TL;DR — You tried a table operation on a table that already exists or is still transitioning (CREATING / UPDATING / DELETING). Check the table's status first, or make the create idempotent by ignoring "already exists".

What it means

ResourceInUseException: Table already exists: <name>
ResourceInUseException: Attempt to change a resource which is still in use: Table is being created/deleted

Control-plane operations (CreateTable, DeleteTable, UpdateTable) require the table to be in a compatible state. This error means it isn't — either it already exists, or it's mid-transition and DynamoDB won't accept another operation until it settles to ACTIVE.

Why it happens

  • Re-running CreateTable for a table that already exists (a repeated migration/deploy, tests that don't clean up).
  • Operating during a transition — creating an index, deleting, or updating while the table is still CREATING/UPDATING.
  • A race — two processes creating the same table concurrently.

How to fix it

  1. Check status before acting. DescribeTable → only proceed when TableStatus is ACTIVE; use a waiter (waitUntilTableExists) to block until it settles.
  2. Make create idempotent. Catch ResourceInUseException on CreateTable and treat it as success (the table you wanted exists).
  3. Serialize table ops in tests/migrations so two don't run at once; clean up test tables in teardown.

Example

import {DynamoDBClient, CreateTableCommand, ResourceInUseException} from '@aws-sdk/client-dynamodb';

const client = new DynamoDBClient({});

try {
  await client.send(new CreateTableCommand(tableDef));
} catch (err) {
  if (!(err instanceof ResourceInUseException)) throw err;
  // Table already exists — that's fine, carry on.
}

Bekerja dengan DynamoDB tanpa Console

DynoTable adalah klien desktop yang cepat untuk DynamoDB — jelajahi tabel, jalankan query gaya SQL, dan edit Item secara lokal.