-
Notifications
You must be signed in to change notification settings - Fork 0
/
05-cleanup.sh
executable file
·37 lines (30 loc) · 1.16 KB
/
05-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
36
#!/bin/bash
. 00-vars.sh
ARN=$(cat .layer.arn.txt)
get_versions () {
echo $(aws lambda list-layer-versions --layer-name "$EXTENSION" --region "$AWS_REGION" --output text --query LayerVersions[].Version | tr '[:blank:]' '\n')
}
echo "Deleting db-client Function"
aws lambda delete-function \
--function-name "${FUNCTION_DB}" \
--region "${AWS_REGION}" > /dev/null
echo "Deleting web-client Function"
aws lambda delete-function \
--function-name "${FUNCTION_WEB}" \
--region "${AWS_REGION}" > /dev/null
echo "Deleting Layers"
versions=$(get_versions)
for version in $versions;
do
echo "deleting arn:aws:lambda:$AWS_REGION:*:layer:$EXTENSION:$version"
aws lambda delete-layer-version --region "$AWS_REGION" --layer-name "$EXTENSION" --version-number "$version" > /dev/null
done
echo "Deleting logs"
while true; do
read -p "Delete function log group (/aws/lambda/*? (y/n)" response
case $response in
[Yy]* ) aws logs delete-log-group --log-group-name /aws/lambda/$FUNCTION_DB > /dev/null; aws logs delete-log-group --log-group-name /aws/lambda/$FUNCTION_WEB > /dev/null; break;;
[Nn]* ) break;;
* ) echo "Response must start with y or n.";;
esac
done