公式ブログ でも案内されている通り 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
追記
ruby2.5 と nodejs10.x も2021年7月30日にサポート終了フェーズ1を迎えるので対象ランタイムを引数で指定するバージョンも後半に追記しました。
全リージョン版
リージョンを横断してリストアップしたいので、上記を全リージョンで回すシェルスクリプトを書きました。
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
対象ランタイムを引数で指定するバージョン
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=='$1'].{ARN:FunctionArn, Runtime:Runtime}"
done
echo "finished"
サンプル
sh list-lambda-functions.sh nodejs10.x
sh list-lambda-functions.sh ruby2.5
引数で渡すランタイム名を間違えると、ちゃんとリストアップされないので注意ください。
参考
公式ブログ::Announcing end of support for Python 2.7 in AWS Lambda
AWS Lambda::ランタイムサポートポリシー
AWS CLI::list-functions
AWS CLI::describe-regions
AWS CLI::出力をフィルタリングする