-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteardown.sh
executable file
·34 lines (28 loc) · 1.23 KB
/
teardown.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
#!/usr/bin/env bash
source ./configuration.sh
# delete deployed services (containers)
ecs-cli compose --file docker-compose.yml `# source the main docker-compose.yml` \
--file docker-compose.aws.yml `# and override it with some AWS specifics` \
service rm \
--cluster-config $CLUSTER_CONFIG_NAME \
--cluster $CLUSTER_NAME \
--ecs-profile $PROFILE_NAME
# destroy the cluster
ecs-cli down --force \
--cluster-config $CLUSTER_CONFIG_NAME \
--ecs-profile $PROFILE_NAME
# delete cloudformation stack created by the ecs-cli
aws cloudformation delete-stack \
--stack-name amazon-ecs-cli-setup-$CLUSTER_NAME
# delete log groups
aws logs delete-log-group \
--log-group-name $TASK_NAME
# delete ECR repositories
for service in $SERVICES_TO_DEPLOY
do
# delete all images first (mandatory)
IMAGES_TO_DELETE=$( aws ecr list-images --repository-name ${PROJECT_NAME}_${service} --query 'imageIds[*]' --output json )
aws ecr batch-delete-image --repository-name ${PROJECT_NAME}_${service} --image-ids "$IMAGES_TO_DELETE" || true
# delete repository
aws ecr delete-repository --repository-name ${PROJECT_NAME}_${service}
done