I need to delete a dynamodb table, and wait until it is completely removed. How can I check this?
boto3 api expose a method get_waiter
to wait for certain events, but it is not well documented. Can I use it for this purpose? Which would be the event name, or maybe handle a ResourceNotFoundException
JavaScript
x
3
1
# Wait until the table exists.
2
table.meta.client.get_waiter('table_exists').wait(TableName='TableName')
3
Advertisement
Answer
After delete_table
API, call table_not_exists
waiter. This waits until the specified table returns 404.
JavaScript
1
7
1
import boto3
2
client = boto3.client('dynamodb')
3
client.delete_table(TableName='foo')
4
waiter = client.get_waiter('table_not_exists')
5
waiter.wait(TableName='foo')
6
print ("table deleted")
7
For create_table
API, call table_exists
waiter. This waits until the specified table gets active.