File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,25 @@ function _list_dynamo_tables() {
158158 done
159159}
160160
161+ function _delete_dynamo_tables() {
162+ local workspace=$1
163+ local tables
164+
165+ if [ -n " $workspace " ]; then
166+ tables=$( aws dynamodb list-tables | jq -r --arg substring1 " ${workspace} -" --arg substring2 " ${workspace} _" ' .TableNames[] | select((. | contains($substring1)) or (. | contains($substring2)))' )
167+
168+ if [ -z " $tables " ]; then
169+ echo -e " ${RED} No DynamoDB tables found.${NC} "
170+ return 0
171+ fi
172+
173+ for table in $tables ; do
174+ echo -e " ${GREEN} Deleting DynamoDB table: ${table} ${NC} "
175+ aws dynamodb delete-table --table-name $table
176+ done
177+ fi
178+ }
179+
161180function _list_s3_buckets() {
162181 local workspace=$1
163182 local buckets
@@ -1150,6 +1169,7 @@ function _delete_workspace_resources() {
11501169 _delete_ssm_parameters " $TERRAFORM_WORKSPACE "
11511170 _delete_secrets " $TERRAFORM_WORKSPACE "
11521171 _delete_lambda_event_source_mappings " $TERRAFORM_WORKSPACE "
1172+ _delete_dynamo_tables " $TERRAFORM_WORKSPACE "
11531173 _delete_resource_groups " $TERRAFORM_WORKSPACE "
11541174}
11551175
You can’t perform that action at this time.
0 commit comments