Deleting S3 Tables resources
Posted: | Tags: aws til cloud s3S3 Tables still does not provide a great console experience despite being around for two-ish years now. This is evident when looking for an easy way to delete the resoure you create with it through the console. So here are some easy AWS CLI commands I’ve been using to delete resources when testing S3 Tables.
First, there’s three resources types that get created, a table, a namespace and a table bucket. You can have multiple tables in a namespace and multiple namespaces in a bucket. With this mapping in mind, you have to be aware that you cannot delete a parent resource without first deleting all its child resources. So you’ll have to work from the bottom up.
In my example below, as it is also common in my testing, I have one resource under each other, so that’s what I’m going with. Deleting resources cannot be undone, so beware!
Piece by piece
Deleting a table can be done from the CLI or through a query (i.e. through Athena, DuckDB or similar). It’s the only one of the three resources that can be modified through queries. Using the CLI it looks like this:
aws s3tables delete-table \
--table-bucket-arn arn:aws:s3tables:us-east-1:111122223333:bucket/amzn-s3-demo-table-bucket \
--namespace example_namespace --name example_table
We have to provide the table bucket ARN, the namespace name, and the table name.
Deleting a namespace looks like this:
aws s3tables delete-namespace \
--table-bucket-arn arn:aws:s3tables:us-east-1:111122223333:bucket/amzn-s3-demo-bucket1 \
--namespace example_namespace
We are providing everything as we did before minus the table name.
Lastly, deleting a table bucket looks like this:
aws s3tables delete-table-bucket \
--table-bucket-arn arn:aws:s3tables:us-east-1:111122223333:bucket/amzn-s3-demo-bucket1
We are providing everything we did for the namespace minus the namespace name.
Doing it all together
To make things easier I have the required parameters as environment variables, this allows me to copy and paste the following commands each time I want to clean up.
TABLE_BUCKET_ARN=arn:aws:s3tables:us-east-1:111122223333:bucket/amzn-s3-demo-table-bucket
NAMEPSACE=example_namespace
TABLE=example_table
aws s3tables delete-table --table-bucket-arn $TABLE_BUCKET_ARN --namespace $NAMESPACE --name $TABLE
aws s3tables delete-namespace --table-bucket-arn $TABLE_BUCKET_ARN --namespace $NAMESPACE
aws s3tables delete-table-bucket --table-bucket-arn $TABLE_BUCKET_ARN
In order to find what resources you have in the first place you can peruse the console or use the CLI list commands.
That’s all!