Skip to content

Instantly share code, notes, and snippets.

@ChaitanyaChandra
Last active May 11, 2022 14:12
Show Gist options
  • Save ChaitanyaChandra/79ce228218ed853c19cb44bd5922e2d4 to your computer and use it in GitHub Desktop.
Save ChaitanyaChandra/79ce228218ed853c19cb44bd5922e2d4 to your computer and use it in GitHub Desktop.
aws cli to upgrade lambda runtime
#!/bin/bash
# listing all functions in csv format using Regular expressions
lambda_fun=$(
aws lambda list-functions \
--function-version ALL \
--region=us-east-2 \
--output text \
--query "Functions[?Runtime=='python3.6'].FunctionName" | sed -E 's/ +/\\n/g')
# adding header to csv and redirecting to file [file.csv]
echo -e "lambda_functions\n$lambda_fun" > file.csv
# updating lambda function by iterating using while loop
i=0
# input file separate
OLDIFS=$IFS
IFS=","
# while loop
while read lambda_functions
do
((i=i+1))
# skipping header
if [ "$i" -eq 1 ]; then
continue
fi
runtime_update=$(
aws lambda update-function-configuration \
--function-name "$lambda_functions" \
--runtime python3.9 --output text --query "Runtime"
)
echo "$lambda_functions" is successfully updated to "$runtime_update"
done < file.csv
IFS=$OLDIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment