Last active
January 18, 2024 19:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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