delete-stack.sh 857 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. set -e
  3. if [ -z "$1" ]; then
  4. echo "ERROR: Configuration file not passed"
  5. echo "Please use ./delete-stack.sh PATH/TO/CONFIG to run this script"
  6. exit 1
  7. else
  8. echo "Using $1 file for config"
  9. source $1
  10. fi
  11. BUCKET_NAME=$(get_aws_export "S3BucketName")
  12. # Delete the CloudFormation stack
  13. echo -e "\n\n=========== Emptying bucket $BUCKET_NAME ==========="
  14. aws s3 rm s3://$BUCKET_NAME --recursive --profile $CLI_PROFILE || echo "No bucket"
  15. echo -e "\n\n=========== Deleting stack $NEW_STACK_NAME ==========="
  16. aws cloudformation delete-stack --stack-name $NEW_STACK_NAME --profile $CLI_PROFILE
  17. echo -e "\n\n=========== Waiting for stack deletion to complete ==========="
  18. aws cloudformation wait stack-delete-complete --stack-name $NEW_STACK_NAME --profile $CLI_PROFILE
  19. echo -e "\n\n=========== Stack $NEW_STACK_NAME deleted ==========="