-
Notifications
You must be signed in to change notification settings - Fork 0
/
4-cleanup.sh
executable file
·35 lines (35 loc) · 1.31 KB
/
4-cleanup.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
35
#!/bin/bash
set -eo pipefail
STACK=aura-lambda
if [[ $# -eq 1 ]] ; then
STACK=$1
echo "Deleting stack $STACK"
fi
FUNCTION=$(aws cloudformation describe-stack-resource --stack-name $STACK --logical-resource-id function --query 'StackResourceDetail.PhysicalResourceId' --output text)
aws cloudformation delete-stack --stack-name $STACK
echo "Deleted $STACK stack."
if [ -f bucket-name.txt ]; then
ARTIFACT_BUCKET=$(cat bucket-name.txt)
if [[ ! $ARTIFACT_BUCKET =~ lambda-artifacts-[a-z0-9]{16} ]] ; then
echo "Bucket was not created by this application. Skipping."
else
while true; do
read -p "Delete deployment artifacts and bucket ($ARTIFACT_BUCKET)? (y/n)" response
case $response in
[Yy]* ) aws s3 rb --force s3://$ARTIFACT_BUCKET; rm bucket-name.txt; break;;
[Nn]* ) break;;
* ) echo "Response must start with y or n.";;
esac
done
fi
fi
while true; do
read -p "Delete function log group (/aws/lambda/$FUNCTION)? (y/n)" response
case $response in
[Yy]* ) aws logs delete-log-group --log-group-name /aws/lambda/$FUNCTION; break;;
[Nn]* ) break;;
* ) echo "Response must start with y or n.";;
esac
done
rm -f out.yml out.json function/*.pyc
rm -rf package function/__pycache__