-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathcleanup.sh
56 lines (44 loc) · 2.53 KB
/
cleanup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
echo
read -p "Stack name: " STACKNAME
VOCABULARY_CONFIG_BUCKET=s3://ivs-transcribe-demo-vocabulary-config-<RANDOM_SUFFIX>
PLAYER_BUCKET=s3://ivs-transcribe-demo-player-app-<RANDOM_SUFFIX>
LAMBDA_FUNCTIONS_BUCKET=s3://ivs-transcribe-demo-lambda-functions-<RANDOM_SUFFIX>
STREAM_REPOSITORY_NAME=ivs-transcribe-demo-stream-images-<RANDOM_SUFFIX>
TRANSCRIBE_REPOSITORY_NAME=ivs-transcribe-demo-transcribe-images-<RANDOM_SUFFIX>
TRANSLATE_REPOSITORY_NAME=ivs-transcribe-demo-translate-images-<RANDOM_SUFFIX>
VOCABULARY_NAME=ivs-transcribe-demo-custom-vocabulary-<RANDOM_SUFFIX>
VOCABULARY_FILTER_NAME=ivs-transcribe-demo-vocabulary-filter-<RANDOM_SUFFIX>
# The following buckets are just emptied, since they are included in the CloudFormation
# template and will be removed along with the stack
printf "\nEmptying bucket \"$VOCABULARY_CONFIG_BUCKET\"...\n"
aws s3 rm $VOCABULARY_CONFIG_BUCKET --recursive --quiet
printf "\nEmptying bucket \"$PLAYER_BUCKET\"...\n"
aws s3 rm $PLAYER_BUCKET --recursive --quiet
# Remove stages to avoid error when deleting APIs:
# "Active stages pointing to this deployment must be moved or deleted"
printf "\nRemoving API Gateway stages...\n"
node delete-api-stages.js --stackName $STACKNAME --stackOutputFilePath stack.json
printf "\nRemoving stack \x1b[33m$STACKNAME\x1b[0m...\n"
aws cloudformation delete-stack --stack-name $STACKNAME
aws cloudformation wait stack-delete-complete --stack-name $STACKNAME
printf "\nRemoving bucket \"$LAMBDA_FUNCTIONS_BUCKET\"...\n"
aws s3 rb $LAMBDA_FUNCTIONS_BUCKET --force
printf "\nRemoving ECR repository \"$STREAM_REPOSITORY_NAME\"...\n"
aws ecr delete-repository --repository-name $STREAM_REPOSITORY_NAME --force
printf "\nRemoving ECR repository \"$TRANSCRIBE_REPOSITORY_NAME\"...\n"
aws ecr delete-repository --repository-name $TRANSCRIBE_REPOSITORY_NAME --force
printf "\nChecking if translate ECR repository exists: \"$TRANSLATE_REPOSITORY_NAME\"\n"
aws ecr describe-repositories --repository-names $TRANSLATE_REPOSITORY_NAME &> /dev/null
if [[ $? == 0 ]]
then
printf "\nRepository found, removing...\n"
aws ecr delete-repository --repository-name $TRANSLATE_REPOSITORY_NAME --force
else
printf "\nRepository not found, skipped\n"
fi
printf "\nRemoving Transcribe custom vocabulary \"$VOCABULARY_NAME\"...\n"
aws transcribe delete-vocabulary --vocabulary-name $VOCABULARY_NAME
printf "\nRemoving Transcribe vocabulary filter \"$VOCABULARY_FILTER_NAME\"...\n"
aws transcribe delete-vocabulary-filter --vocabulary-filter-name $VOCABULARY_FILTER_NAME
printf "\nCleanup complete!\n"