botocore.errorfactory.ResourceInUseException: An error occurred (ResourceInUseException) during CreateTable operation: Cannot create preexisting table
In my case, I was confused with the error message and the actual behaviour of my project -- when I listed tables, there is one table, but when I scanned tables, where were no tables! Why is this ๐?
Error
gitpod /workspace/aws-bootcamp-cruddur-2023/backend-flask (submissions) $ ./bin/ddb/schema-load
Traceback (most recent call last):
File "/workspace/aws-bootcamp-cruddur-2023/backend-flask/./bin/ddb/schema-load", line 20, in <module>
response = dynamodb.create_table(
^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/.pyenv_mirror/user/current/lib/python3.11/site-packages/botocore/client.py", line 530, in _api_call
return self._make_api_call(operation_name, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/.pyenv_mirror/user/current/lib/python3.11/site-packages/botocore/client.py", line 960, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.ResourceInUseException: An error occurred (ResourceInUseException) when calling the CreateTable operation: Cannot create preexisting table
$ ./bin/ddb/scan-tables
{
"Items": [], <--------- There is nothing, no items!
"Count": 0,
"ScannedCount": 0,
"ConsumedCapacity": null
}
$ ./bin/ddb/list-tables
----------------------
| ListTables |
+--------------------+
| cruddur-messages | <--------- There is one table!!!
+--------------------+
Solution
โ 1. Know your code - make sure you understand what each file does.
./backend-flask/bin/ddb/list-tables
: lists tables that exist in the database../backend-flask/bin/ddb/scan-tables
: lists records in a table specified in the command.DynamoDB โโโ **endpoint-url=http://localhost:8000** โโโ **cruddur-messages <------ list-tables, schema-load โ โโโ record 1 <---- **scan-tables, seed** one level deeper โ โโโ record 2 โ โโโ record 3 โ โโโ record ... โ โโโ record n โ โโโ
ย