3

I have around 200 lambda functions that I need to delete. Using the console I can only delete one at a time, which would be really painful. Does anyone know a cli command to bulk delete all the functions? Thanks!

2 Answers 2

5

I've just found an answer using an old script to delete IAM users I had:

aws lambda list-functions --region us-east-1 | jq -r '.Functions | .[] | .FunctionName' |
while read uname1; do
echo "Deleting $uname1";
aws lambda delete-function --region us-east-1 --function-name $uname1;
done
Sign up to request clarification or add additional context in comments.

1 Comment

Note: Had to brew install jq to run this on MacOS
3

A one-liner without having to use jq:

$ region="us-east-1"
$ aws lambda list-functions --region "${region}" --query 'Functions[].FunctionName' --output text | tr "\t" "\n" | xargs -I {} aws lambda delete-function --region "${region}" --function-name {}

1 Comment

I definitely prefer this one-liner and like using the built-in --query option too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.