Last active
January 27, 2025 15:36
-
-
Save pen-pal/a9b4565e669c1c8eea370091b96db24d to your computer and use it in GitHub Desktop.
download lambda code
This file contains hidden or 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 | |
| # 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