1コマンド+対話式で、リージョン横断でリージョン、ランタイム、バージョン、関数名の一部でフィルタリングしてLambdaの一覧を出力できるツールを、OSSで作りました。
目次
概要
1コマンド+対話式で、リージョン横断でリージョン、ランタイム、バージョン、関数名の一部でフィルタリングしてLambdaの一覧を出力できるツールです。
CLIだとリージョンごとにコマンドを投げる必要がありますが、このツールだと1コマンド+対話式で、柔軟な絞り込みを行うことが可能です。
また、結果をCSVファイルとして出力することも可能です。
例えば
シンプルなツールですが、以下のような使い方ができ使い勝手の良いものになりました。
- どのリージョンに何のLambdaが存在するか一覧化する
- EOLを迎えたLambdaがあるかどうか確認する
- 想定しないリージョンにLambdaが存在するかどうか確認する
- 特定の命名規則に基づいたLambdaを一覧化する
lamver
という名前になります。
ソースコード
Go言語で実装しています。
良ければご覧下さい。スターなど頂けると泣いて喜びます。
インストール
Homebrew
brew install go-to-k/tap/lamver
Linux / Darwin (macOS) / Windows
curl -fsSL https://raw.githubusercontent.com/go-to-k/lamver/main/install.sh | sh lamver -h # To install a specific version of lamver # e.g. version 0.8.0 curl -fsSL https://raw.githubusercontent.com/go-to-k/lamver/main/install.sh | sh -s "v0.8.0" lamver -h
aqua
aqua g -i go-to-k/lamver
バイナリ
ソースビルド(開発版)
※Go環境が必要です。
git clone https://github.com/go-to-k/lamver.git
cd lamver
make install
使い方
lamver [-p <profile>] [-r <default region>] [-o <output file path>] [-k <keyword for function name>]
オプション
- -p, --profile(オプション)
- AWSプロファイル名
- (デフォルト: 実行環境のデフォルトのプロファイルが使用されます)
- -r, --region(オプション)
- デフォルトで選択するAWSリージョン
- 出力するリージョンは対話式で選択するため特別指定する必要はありません
- (デフォルト:
us-east-1
ですが、Profileにデフォルトリージョンが設定してある場合はそちらが優先されます)
- デフォルトで選択するAWSリージョン
- -o, --output(オプション)
- -k, --keyword(オプション)
- キーワードで関数名の絞り込みが可能です(大文字・小文字の区別はしません)
コマンド入力の流れ
lamver
コマンドを打つ
❯ lamver
-k
オプション(キーワード)を指定して、そのキーワードを含む関数の絞り込みをすることが可能です(大文字・小文字の区別はしません)。
❯ lamver -k goto
出力したいリージョンを選択
? Select regions you want to search. [Use arrows to move, space to select, <right> to all, <left> to none, type to filter] [x] ap-northeast-1 [ ] ap-northeast-2 [ ] ap-northeast-3 [ ] ap-south-1 [ ] ap-southeast-1 [ ] ap-southeast-2 [ ] ca-central-1 [ ] eu-central-1 [ ] eu-north-1 [ ] eu-west-1 [ ] eu-west-2 [ ] eu-west-3 [ ] sa-east-1 [x] us-east-1 > [x] us-east-2 [ ] us-west-1 [ ] us-west-2
出力したいランタイム/バージョンを選択
? Select runtime values you want to search. [Use arrows to move, space to select, <right> to all, <left> to none, type to filter] > [ ] dotnet6 [ ] dotnetcore1.0 [ ] dotnetcore2.0 [ ] dotnetcore2.1 [ ] dotnetcore3.1 [x] go1.x [ ] java8 [ ] java8.al2 [ ] java11 [ ] java17 [ ] java21 [ ] nodejs [ ] nodejs4.3 [ ] nodejs4.3-edge [ ] nodejs6.10 [ ] nodejs8.10 [ ] nodejs10.x [x] nodejs12.x [ ] nodejs14.x [ ] nodejs16.x [ ] nodejs18.x [ ] nodejs20.x [ ] provided [x] provided.al2 [ ] provided.al2023 [ ] python2.7 [ ] python3.6 [ ] python3.7 [ ] python3.8 [ ] python3.9 [ ] python3.10 [ ] python3.11 [ ] python3.12 [ ] ruby2.5 [ ] ruby2.7 [ ] ruby3.2
関数名の一部でフィルタリング
フィルタリングの必要がない場合、空で構いません(全関数が出力されます)。
大文字小文字の区別はしないので、より手軽に検索できます。
-k
オプションを指定している場合は、このフェーズはスキップされます。
Filter a keyword of function names(case-insensitive): test-goto
結果出力
+--------------+----------------+----------------------+------------------------------+ | RUNTIME | REGION | FUNCTIONNAME | LASTMODIFIED | +--------------+----------------+----------------------+------------------------------+ | go1.x | ap-northeast-1 | TEST-Goto-function2 | 2023-01-07T14:54:23.406+0000 | +--------------+----------------+----------------------+------------------------------+ | go1.x | ap-northeast-1 | test-GOTO-function10 | 2023-01-07T15:29:11.658+0000 | +--------------+----------------+----------------------+------------------------------+ | go1.x | us-east-2 | Test-Goto-function6 | 2023-01-07T15:28:08.507+0000 | +--------------+----------------+----------------------+------------------------------+ | nodejs12.x | ap-northeast-1 | test-goto-function1 | 2023-01-07T14:53:49.141+0000 | +--------------+----------------+----------------------+------------------------------+ | nodejs12.x | us-east-1 | test-goto-function4 | 2023-01-07T15:18:14.191+0000 | +--------------+----------------+----------------------+------------------------------+ | nodejs12.x | us-east-1 | test-goto-function7 | 2023-01-07T15:28:20.921+0000 | +--------------+----------------+----------------------+------------------------------+ | nodejs12.x | us-east-2 | test-goto-function5 | 2023-01-07T15:18:34.408+0000 | +--------------+----------------+----------------------+------------------------------+ | provided.al2 | ap-northeast-1 | test-goto-function8 | 2023-01-07T15:28:34.968+0000 | +--------------+----------------+----------------------+------------------------------+ | provided.al2 | us-east-1 | test-goto-function3 | 2023-01-07T15:17:35.965+0000 | +--------------+----------------+----------------------+------------------------------+ | provided.al2 | us-east-2 | test-goto-function9 | 2023-01-07T15:29:16.107+0000 | +--------------+----------------+----------------------+------------------------------+ INF 10 counts hit!
CSV出力モード
デフォルトではテーブル形式で出力されます。
上記オプション項目で述べたように、-o
オプションを付けてパスを指定することで、CSVファイルとして出力することができます。
lamver -o ./result.csv
最後に
かなりシンプルなツールですが、意外と使い所があるのではないかと思います。
良ければぜひどうぞ!