1
1
#! /bin/bash
2
2
3
3
echo ---------------------------------------------------------------------------------------------
4
- echo This script destroys the CDK stack
4
+ echo This script destroys the resources created in the workshop
5
5
echo ---------------------------------------------------------------------------------------------
6
6
7
7
if [ -z " $AWS_REGION " ]; then
11
11
12
12
# Disable Contributor Insights
13
13
DDB_CONTRIB=$( aws ssm get-parameter --name ' /petstore/dynamodbtablename' | jq .Parameter.Value -r)
14
- aws dynamodb update-contributor-insights --table-name $DDB_CONTRIB --contributor-insights-action DISABLE
14
+ aws dynamodb update-contributor-insights --table-name $DDB_CONTRIB --contributor-insights-action DISABLE
15
15
16
16
echo STARTING SERVICES CLEANUP
17
17
echo -----------------------------
@@ -22,25 +22,28 @@ STACK_NAME_APP=$(aws ssm get-parameter --name '/eks/petsite/stackname' --region
22
22
23
23
# Set default name in case Parameters are gone (partial deletion)
24
24
if [ -z $STACK_NAME ]; then STACK_NAME=" Services" ; fi
25
- if [ -z $STACK_NAME_APP ]; then STACK_NAME_APP=" Applications" ; fi
25
+ if [ -z $STACK_NAME_APP ]; then STACK_NAME_APP=" Applications" ; fi
26
+ if [ -z $STACK_NAME_CODEPIPELINE ]; then STACK_NAME_CODEPIPELINE=" Observability-Workshop" ; fi
26
27
27
28
# Fix for CDK teardown issues
28
29
aws eks update-kubeconfig --name PetSite
29
30
kubectl delete -f https://raw.githubusercontent.com/aws-samples/one-observability-demo/main/PetAdoptions/cdk/pet_stack/resources/load_balancer/crds.yaml
30
31
31
- # Deleting keycloak
32
+ # Deleting keycloak
32
33
kubectl delete namespace keycloak --force
33
34
34
- # Get rid of all resources (Application first, then cluster or it will fail)
35
- cdk destroy $STACK_NAME_APP --force
36
- cdk destroy $STACK_NAME --force
37
-
38
35
# Sometimes the SqlSeeder doesn't get deleted cleanly. This helps clean up the environment completely including Sqlseeder
39
36
aws cloudformation delete-stack --stack-name $STACK_NAME_APP
37
+ aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME_APP
40
38
aws cloudformation delete-stack --stack-name $STACK_NAME
39
+ aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME
41
40
42
41
aws cloudwatch delete-dashboards --dashboard-names " EKS_FluentBit_Dashboard"
43
42
43
+ # delete the code pipeline stack
44
+ aws cloudformation delete-stack --stack-name $STACK_NAME_CODEPIPELINE
45
+ aws cloudformation wait stack-delete-complete --stack-name $STACK_NAME_CODEPIPELINE
46
+
44
47
echo CDK BOOTSTRAP WAS NOT DELETED
45
48
46
49
echo ----- ✅ DONE --------
0 commit comments