Skip to content

Commit 5ea5c47

Browse files
committed
Delete Dynamo tables
1 parent a7a5d73 commit 5ea5c47

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

scripts/list_workspace_resource.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
161180
function _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

0 commit comments

Comments
 (0)