Created
January 5, 2016 19:17
-
-
Save jankei/2085f55de1d70e339fad to your computer and use it in GitHub Desktop.
deletes old versions of lambdas that aren't aliased
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for (( i=1; i<=$2; i++ )) | |
do | |
aws lambda delete-function --function-name $1 --qualifier $i &>/dev/null | |
echo "lambda $1 version $i was deleted" | |
done |
What if I need to keep only 10 version from lambda functions and rest one is deleted
`#!/bin/bash
fnlist=(
'SAMPLE FUNCTION'
Add more functions here
)
count=0
while [ "x${fnlist[count]}" != "x" ]
do
for (( i=1; i<=$1; i++ ))
do
aws lambda delete-function --function-name ${fnlist[count]} --qualifier $i
echo "lambda ${fnlist[count]} version $i was deleted"
done
count=$(( $count + 1 ))
done
`
sorry about the formatting. i did a bit more to allow for the deletion of multiple functions as a loop
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For those who end up downloading this file, please remember to add executing permissions to the file.
In the Terminal go to the folder where this file is located and type in the following command.
chmod +x deleteLambdas.sh
PS - Thank you for this, @jankei!