公式ブログでも案内されている通り 2021年7月15 日に AWS Lambda での Python 2.7 サポートが終了予定です。
このブログの中で
Python 2.7 のLambdaをリストアップするaws cliコマンドを提示してくれています
aws lambda list-functions --output text --query "Functions[?Runtime=='python2.7'].FunctionArn"
例えばap-northeast-1を対象にすると、こんな感じで出力される
arn:aws:lambda:ap-northeast-1:111111111111:function:xxxxx arn:aws:lambda:ap-northeast-1:111111111111:function:yyyyy
全リージョン版
リージョンを横断してリストアップしたいので、上記を全リージョンで回すシェルスクリプトを書きました。
list-py27functions.sh
for region in `aws ec2 describe-regions --query "Regions[].RegionName" --region us-west-1 --output text` do echo "[${region}]" aws lambda list-functions --region ${region} --output text --query "Functions[?Runtime=='python2.7'].{ARN:FunctionArn, Runtime:Runtime}" done echo "finished"
Usage
export AWS_PROFILE=xxxx # デフォルトプロファイルを常に設定しているなら不要 sh list-py27functions.sh
プロファイルを指定する以外に、権限を持っているユーザーでマネコンにログインしてCloudShellから打つという使い方もできます。
こんな感じで出力します。
[eu-north-1] [ap-south-1] [eu-west-3] [eu-west-2] [eu-west-1] [ap-northeast-3] [ap-northeast-2] [ap-northeast-1] arn:aws:lambda:ap-northeast-1:111111111111:function:xxxxx python2.7 arn:aws:lambda:ap-northeast-1:111111111111:function:yyyyy python2.7 [ca-central-1] [ap-east-1] [ap-southeast-1] [ap-southeast-2] [eu-central-1] [us-east-1] arn:aws:lambda:us-east-1:111111111111:function:test python2.7 [us-east-2] [us-west-1] [us-west-2] arn:aws:lambda:us-west-2:111111111111:function:zzzz python2.7 finished
参考
公式ブログ::Announcing end of support for Python 2.7 in AWS Lambda
AWS CLI::list-functions
AWS CLI::describe-regions
AWS CLI::出力をフィルタリングする