Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash script to download all your Lambda functions.
#!/usr/bin/env bash
#You need to have aws-cli installed and configured
#Credits to Reddit user u/aa93 for the suggestions
mkdir code
aws lambda list-functions | \
grep FunctionName | \
cut -d '"' -f4 | \
while read -r name; do
aws lambda get-function --function-name $name | tail -n 3 | egrep -o 'https?://[^ ]+' | sed 's/"//' | xargs wget -O ./code/$name.zip
done
@kitobelix

This comment has been minimized.

Copy link

@kitobelix kitobelix commented Mar 18, 2019

I had to patch it because the output from get-function doesn't always came in the same order. I used jq as: aws lambda get-function --function-name $name | jq -r '.Code.Location' | xargs wget -O ./code/$name.zip in line 10 and it worked flawlessly.

Thank you very much!

@drajesh209

This comment has been minimized.

Copy link

@drajesh209 drajesh209 commented Dec 23, 2019

Working flawlessly. Thanks for sharing

@yyano

This comment has been minimized.

Copy link

@yyano yyano commented Dec 29, 2019

I used export source code w/ function Configurations.
aws lambda get-function --function-name $name | tee ./code/$name.json | jq -r '.Code.Location' | xargs wget -O ./code/$name.zip

Thank you!

@panchuprodhan

This comment has been minimized.

Copy link

@panchuprodhan panchuprodhan commented Feb 3, 2020

It's not working for me, just generating the folder "code"; nothing else.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment