@@ -4,6 +4,11 @@ echo ---------------------------------------------------------------------------
44echo This script destroys the CDK stack
55echo ---------------------------------------------------------------------------------------------
66
7+ if [ -z " $AWS_REGION " ]; then
8+ echo " Fatal: environment variable AWS_REGION not set. Aborting."
9+ exit 1
10+ fi
11+
712# Disable Contributor Insights
813DDB_CONTRIB=$( aws ssm get-parameter --name ' /petstore/dynamodbtablename' | jq .Parameter.Value -r)
914aws dynamodb update-contributor-insights --table-name $DDB_CONTRIB --contributor-insights-action DISABLE
@@ -21,24 +26,18 @@ if [ -z $STACK_NAME_APP ]; then STACK_NAME_APP="Applications"; fi
2126
2227# Fix for CDK teardown issues
2328aws eks update-kubeconfig --name PetSite
24- kubectl delete -f . /resources/load_balancer/crds.yaml
29+ kubectl delete -f https://raw.githubusercontent.com/aws-samples/one-observability-demo/main/PetAdoptions/cdk/pet_stack /resources/load_balancer/crds.yaml
2530
2631# Get rid of all resources (Application first, then cluster or it will fail)
27- cdk destroy $STACK_NAME_APP $STACK_NAME --force
32+ cdk destroy $STACK_NAME_APP --force
2833cdk destroy $STACK_NAME --force
2934
3035# Sometimes the SqlSeeder doesn't get deleted cleanly. This helps clean up the environment completely including Sqlseeder
31- aws cloudformation delete-stack --stack-name $STACK_NAME
3236aws cloudformation delete-stack --stack-name $STACK_NAME_APP
37+ aws cloudformation delete-stack --stack-name $STACK_NAME
3338
3439aws cloudwatch delete-dashboards --dashboard-names " EKS_FluentBit_Dashboard"
3540
36- # delete s3 buckets
37- for b in $( aws s3 ls | awk ' /services-s3bucketpetadoption/ {print $3}' ) ; do
38- echo " deleting ${b} "
39- aws s3 rb s3://$b --force
40- done
41-
4241echo CDK BOOTSTRAP WAS NOT DELETED
4342
4443echo ----- ✅ DONE --------
0 commit comments