Table of Contents

The Error

Error creating DynamoDB Table: ResourceInUseException: Table already exists

What Causes This

A DynamoDB table with the same name already exists in the same region. DynamoDB table names must be unique per region per account. This also occurs if the table is being created/deleted concurrently.

How to Fix It

Solution 1: Import the Existing Table

terraform import aws_dynamodb_table.users my-users-table

Solution 2: Check Table Status

# The table might be in a transitional state
aws dynamodb describe-table --table-name my-table \
  --query 'Table.TableStatus'

# CREATING, UPDATING, DELETING — wait for it to finish
# ACTIVE — table exists, import or rename

Solution 3: Use Unique Names

resource "aws_dynamodb_table" "users" {
  name         = "${var.project}-${var.environment}-users"
  billing_mode = "PAY_PER_REQUEST"
  hash_key     = "UserId"

  attribute {
    name = "UserId"
    type = "S"
  }
}

Solution 4: Wait for Deletion

# If a previous destroy is still in progress
aws dynamodb wait table-not-exists --table-name my-table
terraform apply

Prevention Tips

  1. Pin provider versions — avoid surprise breaking changes
  2. Use CI/CD — catch errors before they hit production
  3. Test with terraform plan — always review before applying
  4. Keep Terraform updated — newer versions have better error messages
  5. Use terraform validate — catches syntax errors early

Hands-On Courses

Learn to avoid these errors with interactive, project-based courses:

Conclusion

This error is common and fixable. Follow the solutions above, and check our Terraform course for hands-on training that covers real-world troubleshooting scenarios.