AWS/AWS Lambda

AWS Lambda runtime change script

워니주니구니 2023. 11. 6. 18:03
728x90
SMALL

- 개요

AWS Lambda functions의 runtime version을 확인하고 일괄 변경하는 스크립트를 정리해봤다. 최근 Lambda runtime python3.7이 deprecated(2023년 11월 27일)가 될 시기에 맞아서 3.7에서 3.9로 변경하는 스크립트를 간단히 예시로 정리해봤다.

 

 

- 스크립트

for i in $(aws lambda list-functions --function-version ALL --region ap-northeast-2 --output text --query "Functions[?Runtime=='python3.7'].FunctionName"  --output text)
do
        res=$(aws lambda update-function-configuration --function-name "$i" --runtime python3.9 --output text --query "Runtime")
        echo "$i" is successfully updated to "$res"
done

 

 

- 결과

<Lambda function a> is successfully updated to python3.9
<Lambda function b> is successfully updated to python3.9
<Lambda function c> is successfully updated to python3.9
<Lambda function d> is successfully updated to python3.9

 

 

- 참고

https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
https://repost.aws/questions/QUKthaOaroTtaGRQ4ZNjRwDw/script-to-update-python-runtime-from-3-6-to-3-9-in-lambda-functions

 

728x90
LIST