Skip to content

Instantly share code, notes, and snippets.

@pen-pal
Last active January 27, 2025 15:36
Show Gist options
  • Save pen-pal/a9b4565e669c1c8eea370091b96db24d to your computer and use it in GitHub Desktop.
Save pen-pal/a9b4565e669c1c8eea370091b96db24d to your computer and use it in GitHub Desktop.
download lambda code
#!/bin/bash
# Replace with your list of function names
REGION=${1:-"us-east-1"}
PROFILE=${2:-"default"}
function_names=("lambda-1" "lambda-2")
for function in "${function_names[@]}"; do
echo "Downloading code for function: $function"
# Get the URL for the Lambda function code
url=$(aws lambda get-function --function-name "$function" --profile $PROFILE --query 'Code.Location' --output text)
echo $url
# Check if the URL is valid
if [[ "$url" == http* ]]; then
# Download the Lambda code using wget
wget "$url" -O "$function.zip"
echo "Code for $function downloaded as $function.zip"
else
echo "Failed to get code for $function. URL: $url"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment