Skip to content

Instantly share code, notes, and snippets.

@reegz
Created July 22, 2019 12:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reegz/96d552b348fd5f8f4d7bfc3556e9ca98 to your computer and use it in GitHub Desktop.
Save reegz/96d552b348fd5f8f4d7bfc3556e9ca98 to your computer and use it in GitHub Desktop.
Quick bash script to sequentially download AWS Lambda functions linked to the current AWS profile. Relies on the output format being in JSON.
# !/bin/sh
## List the names of all Lambda functions. Can be constrained by using --max-items
for i in `aws lambda list-functions | grep FunctionName | cut -d ":" -f2 | cut -d '"' -f2`
do
echo 'Fetching code for function:' $i
## Using each name, get the function details and then download the zip file containing the source code.
aws lambda get-function --function-name $i | grep Location | awk -F' ' '{print $2}' | xargs wget -O $i.zip
echo 'Code downloaded to' $i.zip
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment