Skip to content

Instantly share code, notes, and snippets.

@jankei
Created January 5, 2016 19:17
Show Gist options
  • Select an option

  • Save jankei/2085f55de1d70e339fad to your computer and use it in GitHub Desktop.

Select an option

Save jankei/2085f55de1d70e339fad to your computer and use it in GitHub Desktop.
deletes old versions of lambdas that aren't aliased
#!/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
@MohitDhanjani

Copy link
Copy Markdown

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!

@rkstar007

Copy link
Copy Markdown

What if I need to keep only 10 version from lambda functions and rest one is deleted

@jaga-me

jaga-me commented Jul 5, 2018

Copy link
Copy Markdown

`#!/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
`

@jaga-me

jaga-me commented Jul 5, 2018

Copy link
Copy Markdown

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