Skip to main content

Cleaning Up Resources

Objective

This guide shows you how to delete all the resources you created in this workshop.

Initial Setup

Navigate to the root directory of the python-fastapi-demo-docker project where your environment variables are sourced:

cd ~/environment/python-fastapi-demo-docker

Cleanup

To avoid incurring future charges, you should delete the resources you created during this workshop.

  1. Retrieve the EFS ID (e.g., fs-040f4681791902287) you configured in the previous lab exercise, then replace the sample value in eks/efs-pv.yaml with your EFS ID.
echo $file_system_id
  1. Run the following commands to delete all resources created in this workshop.
# Delete the ECR repository
aws ecr delete-repository --repository-name fastapi-microservices --force

# Delete FastAPI services
kubectl delete -f eks/deploy-app-python.yaml

# Delete PostgreSQL services
kubectl delete -f eks/deploy-db-python-fargate.yaml

# Delete the Persistent Volume Claim (PVC)
kubectl delete pvc postgres-data-fastapi-postgres-0 -n my-cool-app

# Delete the Persistent Volume (PV)
kubectl delete -f eks/efs-pv.yaml

# Delete the Storage Class
kubectl delete -f eks/efs-sc.yaml

# Delete all mount targets associated with your EFS file system
for mount_target_id in $(aws efs describe-mount-targets --file-system-id $file_system_id --output text --query 'MountTargets[*].MountTargetId'); do
aws efs delete-mount-target --mount-target-id "$mount_target_id"
done

# Delete the cluster
eksctl delete cluster -f eks/create-fargate-python.yaml