Skip to content

Instantly share code, notes, and snippets.

@jderrett
Last active January 18, 2024 19:18
Show Gist options
  • Save jderrett/64478c75ad25552bb27519415d3b5bbd to your computer and use it in GitHub Desktop.
Save jderrett/64478c75ad25552bb27519415d3b5bbd to your computer and use it in GitHub Desktop.
Bash script to download Lambda function source code to zip files via AWS CLI assuming credentials and assuming jq is installed
#!/bin/bash
# Script to download AWS Lambda function code to zip files
# This assumes that AWS CLI, curl, and jq are installed
# List all functions in your account
for fnName in $( aws lambda list-functions | jq -r '.Functions[].FunctionName' ); do
# Get code location (zip file format)
codeLocation=$( aws lambda get-function --function-name $fnName | jq -r '.Code.Location' )
# echo codeLocation: $codeLocation
# Actually download the code (zip file)
fileName="$fnName.zip"
echo fileName: $fileName
curl -o $fileName $codeLocation
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment