lambda-function-search 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +142 -28
- package/bin/run +10 -5
- package/lib/index.d.ts +16 -17
- package/lib/index.js +143 -122
- package/package.json +34 -23
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
lambda-function-search
|
|
2
2
|
======================
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
A CLI tool to search and list AWS Lambda functions across regions with filtering capabilities.
|
|
5
5
|
|
|
6
6
|
[](https://oclif.io)
|
|
7
7
|
[](https://npmjs.org/package/lambda-function-search)
|
|
@@ -9,16 +9,47 @@ Search your Lambda functions
|
|
|
9
9
|
[](https://github.com/hideokamoto/lambda-function-search/blob/master/package.json)
|
|
10
10
|
|
|
11
11
|
<!-- toc -->
|
|
12
|
-
# Install
|
|
13
12
|
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- Node.js >= 18.0.0
|
|
16
|
+
- AWS credentials configured (via AWS CLI, environment variables, or IAM role)
|
|
17
|
+
|
|
18
|
+
## What's New in v0.6.0
|
|
19
|
+
|
|
20
|
+
- ✨ **Modernized Dependencies**: Migrated to AWS SDK v3 and oclif v4
|
|
21
|
+
- 🔒 **Security**: Fixed all 12 security vulnerabilities
|
|
22
|
+
- 🚀 **Updated Runtime Support**: Added support for latest Lambda runtimes (Node.js 18/20/22, Python 3.11/3.12/3.13, etc.)
|
|
23
|
+
- 🌍 **Expanded Regions**: Updated AWS region list to include all current regions (29 regions supported)
|
|
24
|
+
- 🛠️ **Developer Experience**: Migrated from TSLint to ESLint, updated TypeScript to v5
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
### Global Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm i -g lambda-function-search
|
|
14
32
|
```
|
|
15
|
-
$ npm i -g lambda-function-search
|
|
16
33
|
|
|
34
|
+
After installation, you can use the `lfs` or `lambda-function-search` command.
|
|
35
|
+
|
|
36
|
+
### Using with npx (No Installation Required)
|
|
37
|
+
|
|
38
|
+
You can use the tool directly with `npx` without installing it globally:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx lambda-function-search --region us-east-1
|
|
17
42
|
```
|
|
18
43
|
|
|
19
|
-
|
|
44
|
+
Or use the shorter alias:
|
|
20
45
|
|
|
46
|
+
```bash
|
|
47
|
+
npx lfs --region us-east-1
|
|
21
48
|
```
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
|
|
52
|
+
```bash
|
|
22
53
|
$ lfs --help
|
|
23
54
|
Search Lambda functions
|
|
24
55
|
|
|
@@ -26,31 +57,39 @@ USAGE
|
|
|
26
57
|
$ lambda-function-search
|
|
27
58
|
|
|
28
59
|
OPTIONS
|
|
29
|
-
-A, --showAll Show all function data
|
|
60
|
+
-A, --showAll Show all function data (full JSON output)
|
|
30
61
|
|
|
31
|
-
-R, --runtime=runtime Lambda runtime
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
62
|
+
-R, --runtime=runtime Filter by Lambda runtime
|
|
63
|
+
Examples: nodejs18.x, nodejs20.x, nodejs22.x,
|
|
64
|
+
python3.11, python3.12, python3.13,
|
|
65
|
+
java11, java17, java21,
|
|
66
|
+
dotnet6, dotnet8,
|
|
67
|
+
ruby3.2, ruby3.3,
|
|
68
|
+
provided.al2, provided.al2023
|
|
36
69
|
|
|
37
|
-
-h, --help
|
|
70
|
+
-h, --help Show CLI help
|
|
38
71
|
|
|
39
|
-
-p, --profile=profile AWS CLI profile
|
|
72
|
+
-p, --profile=profile AWS CLI profile name
|
|
40
73
|
|
|
41
|
-
-r, --region=region region
|
|
74
|
+
-r, --region=region AWS region (use "all" to search all regions)
|
|
42
75
|
|
|
43
|
-
-s, --search=search
|
|
76
|
+
-s, --search=search Search by function name (regex supported)
|
|
44
77
|
```
|
|
45
78
|
|
|
46
|
-
|
|
47
|
-
|
|
79
|
+
## Examples
|
|
80
|
+
|
|
81
|
+
> **Note**: If you installed globally, you can use `lfs` or `lambda-function-search`. If using `npx`, replace `lfs` with `npx lambda-function-search` or `npx lfs`.
|
|
82
|
+
|
|
83
|
+
### List All Functions in a Region
|
|
48
84
|
|
|
49
|
-
## List all Function
|
|
50
85
|
```bash
|
|
86
|
+
# With global installation
|
|
51
87
|
$ lfs --region us-east-1
|
|
52
|
-
|
|
53
|
-
|
|
88
|
+
|
|
89
|
+
# Or with npx (no installation required)
|
|
90
|
+
$ npx lambda-function-search --region us-east-1
|
|
91
|
+
=== Matched Functions: 5 / 5 ===
|
|
92
|
+
Region : us-east-1
|
|
54
93
|
ContactFormLambda
|
|
55
94
|
serverlessContactForm
|
|
56
95
|
HelloAlexa
|
|
@@ -58,10 +97,11 @@ Example
|
|
|
58
97
|
ServerlessTest
|
|
59
98
|
```
|
|
60
99
|
|
|
61
|
-
|
|
100
|
+
### List All Functions Across All Regions
|
|
62
101
|
|
|
63
102
|
```bash
|
|
64
103
|
$ lfs --region all
|
|
104
|
+
# Or: npx lambda-function-search --region all
|
|
65
105
|
=== Matched Functions: 5 / 5 ===
|
|
66
106
|
Region : ap-northeast-2
|
|
67
107
|
ContactFormLambda
|
|
@@ -76,13 +116,14 @@ serverlessContactForm
|
|
|
76
116
|
...
|
|
77
117
|
```
|
|
78
118
|
|
|
79
|
-
|
|
119
|
+
### Search by Runtime
|
|
80
120
|
|
|
81
121
|
```bash
|
|
82
|
-
$ lfs --region us-east-1 --runtime
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
122
|
+
$ lfs --region us-east-1 --runtime nodejs20.x
|
|
123
|
+
# Or: npx lambda-function-search --region us-east-1 --runtime nodejs20.x
|
|
124
|
+
Search condition: Runtime === nodejs20.x
|
|
125
|
+
=== Matched Functions: 5 / 43 ===
|
|
126
|
+
Region : us-east-1
|
|
86
127
|
ContactFormLambda
|
|
87
128
|
serverlessContactForm
|
|
88
129
|
HelloAlexa
|
|
@@ -90,13 +131,86 @@ Example
|
|
|
90
131
|
ServerlessTest
|
|
91
132
|
```
|
|
92
133
|
|
|
93
|
-
|
|
134
|
+
### Search by Function Name
|
|
94
135
|
|
|
95
136
|
```bash
|
|
96
137
|
$ lfs --region us-east-1 --search Form
|
|
138
|
+
# Or: npx lambda-function-search --region us-east-1 --search Form
|
|
97
139
|
Search condition: FunctionName contains Form
|
|
98
|
-
Matched Functions: 2 / 43
|
|
99
|
-
|
|
140
|
+
=== Matched Functions: 2 / 43 ===
|
|
141
|
+
Region : us-east-1
|
|
100
142
|
ContactFormLambda
|
|
101
143
|
serverlessContactForm
|
|
102
144
|
```
|
|
145
|
+
|
|
146
|
+
### Show Full Function Details
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
$ lfs --region us-east-1 --search Form --showAll
|
|
150
|
+
# Or: npx lambda-function-search --region us-east-1 --search Form --showAll
|
|
151
|
+
Search condition: FunctionName contains Form
|
|
152
|
+
=== Matched Functions: 2 / 43 ===
|
|
153
|
+
Region : us-east-1
|
|
154
|
+
ContactFormLambda
|
|
155
|
+
{
|
|
156
|
+
FunctionName: 'ContactFormLambda',
|
|
157
|
+
FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:ContactFormLambda',
|
|
158
|
+
Runtime: 'nodejs20.x',
|
|
159
|
+
Role: 'arn:aws:iam::123456789012:role/lambda-role',
|
|
160
|
+
...
|
|
161
|
+
}
|
|
162
|
+
serverlessContactForm
|
|
163
|
+
{
|
|
164
|
+
FunctionName: 'serverlessContactForm',
|
|
165
|
+
...
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Use AWS Profile
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
$ lfs --region us-east-1 --profile my-profile
|
|
173
|
+
# Or: npx lambda-function-search --region us-east-1 --profile my-profile
|
|
174
|
+
=== Matched Functions: 5 / 5 ===
|
|
175
|
+
Region : us-east-1
|
|
176
|
+
...
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Combine Filters
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
$ lfs --region us-east-1 --runtime nodejs20.x --search Form
|
|
183
|
+
# Or: npx lambda-function-search --region us-east-1 --runtime nodejs20.x --search Form
|
|
184
|
+
Search condition: Runtime === nodejs20.x
|
|
185
|
+
Search condition: FunctionName contains Form
|
|
186
|
+
=== Matched Functions: 2 / 43 ===
|
|
187
|
+
Region : us-east-1
|
|
188
|
+
ContactFormLambda
|
|
189
|
+
serverlessContactForm
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Supported Regions
|
|
193
|
+
|
|
194
|
+
The tool supports all 29 AWS regions:
|
|
195
|
+
- **Africa**: af-south-1
|
|
196
|
+
- **Asia Pacific**: ap-east-1, ap-northeast-1, ap-northeast-2, ap-northeast-3, ap-south-1, ap-south-2, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-4
|
|
197
|
+
- **Canada**: ca-central-1, ca-west-1
|
|
198
|
+
- **Europe**: eu-central-1, eu-central-2, eu-north-1, eu-south-1, eu-south-2, eu-west-1, eu-west-2, eu-west-3
|
|
199
|
+
- **Middle East**: il-central-1, me-central-1, me-south-1
|
|
200
|
+
- **South America**: sa-east-1
|
|
201
|
+
- **United States**: us-east-1, us-east-2, us-west-1, us-west-2
|
|
202
|
+
|
|
203
|
+
## Supported Runtimes
|
|
204
|
+
|
|
205
|
+
The tool supports filtering by all Lambda runtimes, including:
|
|
206
|
+
- **Node.js**: nodejs18.x, nodejs20.x, nodejs22.x (and older versions)
|
|
207
|
+
- **Python**: python3.11, python3.12, python3.13 (and older versions)
|
|
208
|
+
- **Java**: java11, java17, java21 (and older versions)
|
|
209
|
+
- **.NET**: dotnet6, dotnet8 (and older versions)
|
|
210
|
+
- **Ruby**: ruby3.2, ruby3.3 (and older versions)
|
|
211
|
+
- **Custom**: provided, provided.al2, provided.al2023
|
|
212
|
+
- **Go**: go1.x
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
MIT
|
package/bin/run
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const fs = require('fs')
|
|
4
3
|
const path = require('path')
|
|
5
|
-
const
|
|
4
|
+
const oclif = require('@oclif/core')
|
|
5
|
+
const flush = require('@oclif/core/flush')
|
|
6
|
+
const handle = require('@oclif/core/handle')
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
const run = async () => {
|
|
9
|
+
await oclif.run(process.argv.slice(2), {
|
|
10
|
+
root: path.join(__dirname, '..'),
|
|
11
|
+
pjson: require('../package.json')
|
|
12
|
+
})
|
|
13
|
+
}
|
|
8
14
|
|
|
9
|
-
|
|
10
|
-
.catch(require('@oclif/errors/handle'))
|
|
15
|
+
run().then(flush).catch(handle)
|
package/lib/index.d.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import { Command
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare type ISearchQuery = {
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
type IRuntime = 'nodejs' | 'nodejs4.3' | 'nodejs6.10' | 'nodejs8.10' | 'nodejs10.x' | 'nodejs12.x' | 'nodejs14.x' | 'nodejs16.x' | 'nodejs18.x' | 'nodejs20.x' | 'nodejs22.x' | 'python2.7' | 'python3.6' | 'python3.7' | 'python3.8' | 'python3.9' | 'python3.10' | 'python3.11' | 'python3.12' | 'python3.13' | 'java8' | 'java8.al2' | 'java11' | 'java17' | 'java21' | 'dotnetcore1.0' | 'dotnetcore2.0' | 'dotnetcore2.1' | 'dotnetcore3.1' | 'dotnet6' | 'dotnet8' | 'go1.x' | 'ruby2.5' | 'ruby2.7' | 'ruby3.2' | 'ruby3.3' | 'provided' | 'provided.al2' | 'provided.al2023' | string;
|
|
3
|
+
type ISearchQuery = {
|
|
5
4
|
Runtime?: IRuntime;
|
|
6
5
|
name?: string;
|
|
7
6
|
};
|
|
8
7
|
declare class LambdaFunctionSearch extends Command {
|
|
9
8
|
static description: string;
|
|
10
|
-
|
|
11
|
-
private amount;
|
|
12
|
-
private client;
|
|
9
|
+
static examples: string[];
|
|
13
10
|
static flags: {
|
|
14
|
-
help: import("@oclif/
|
|
15
|
-
runtime:
|
|
16
|
-
region:
|
|
17
|
-
profile:
|
|
18
|
-
search:
|
|
19
|
-
showAll: import("@oclif/
|
|
11
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
12
|
+
runtime: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
region: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
profile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
search: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
16
|
+
showAll: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
20
17
|
};
|
|
21
|
-
listAllFunctions
|
|
22
|
-
getAllRegionFuncs(query: ISearchQuery,
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
private listAllFunctions;
|
|
19
|
+
getAllRegionFuncs(query: ISearchQuery, clientConfig: {
|
|
20
|
+
profile?: string;
|
|
21
|
+
}, showAll: boolean): Promise<void>;
|
|
22
|
+
run(): Promise<void>;
|
|
23
|
+
private worker;
|
|
25
24
|
}
|
|
26
25
|
export = LambdaFunctionSearch;
|
package/lib/index.js
CHANGED
|
@@ -1,169 +1,190 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
}
|
|
2
|
+
const tslib_1 = require("tslib");
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
5
|
+
const credential_providers_1 = require("@aws-sdk/credential-providers");
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
function createQueryBuilder(log) {
|
|
8
|
+
const query = {};
|
|
9
|
+
return {
|
|
10
|
+
addRuntime(runtime) {
|
|
11
|
+
log(`${chalk_1.default.green('Search condition')}: Runtime === ${runtime}`);
|
|
12
|
+
query.Runtime = runtime;
|
|
13
|
+
return this;
|
|
14
|
+
},
|
|
15
|
+
addSearchQuery(name) {
|
|
16
|
+
log(`${chalk_1.default.green('Search condition')}: FunctionName contains ${name}`);
|
|
17
|
+
query.name = name;
|
|
18
|
+
return this;
|
|
19
|
+
},
|
|
20
|
+
getQuery() {
|
|
21
|
+
return query;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
24
|
}
|
|
25
25
|
const regions = [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
'af-south-1',
|
|
27
|
+
'ap-east-1',
|
|
28
|
+
'ap-northeast-1',
|
|
29
|
+
'ap-northeast-2',
|
|
30
|
+
'ap-northeast-3',
|
|
31
|
+
'ap-south-1',
|
|
32
|
+
'ap-south-2',
|
|
33
|
+
'ap-southeast-1',
|
|
34
|
+
'ap-southeast-2',
|
|
35
|
+
'ap-southeast-3',
|
|
36
|
+
'ap-southeast-4',
|
|
37
|
+
'ca-central-1',
|
|
38
|
+
'ca-west-1',
|
|
39
|
+
'eu-central-1',
|
|
40
|
+
'eu-central-2',
|
|
41
|
+
'eu-north-1',
|
|
42
|
+
'eu-south-1',
|
|
43
|
+
'eu-south-2',
|
|
44
|
+
'eu-west-1',
|
|
45
|
+
'eu-west-2',
|
|
46
|
+
'eu-west-3',
|
|
47
|
+
'il-central-1',
|
|
48
|
+
'me-central-1',
|
|
49
|
+
'me-south-1',
|
|
50
|
+
'sa-east-1',
|
|
51
|
+
'us-east-1',
|
|
52
|
+
'us-east-2',
|
|
53
|
+
'us-west-1',
|
|
54
|
+
'us-west-2',
|
|
42
55
|
];
|
|
43
|
-
class LambdaFunctionSearch extends
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.amount = 0;
|
|
48
|
-
}
|
|
49
|
-
async listAllFunctions(query = {}, functions = []) {
|
|
50
|
-
if (!this.client) {
|
|
51
|
-
throw new Error('Failed to initilize AWS SDK Class');
|
|
52
|
-
}
|
|
53
|
-
const params = {};
|
|
54
|
-
if (this.NextMarker)
|
|
55
|
-
params.Marker = this.NextMarker;
|
|
56
|
-
const { NextMarker, Functions } = await this.client.listFunctions(params).promise();
|
|
57
|
-
this.NextMarker = NextMarker || '';
|
|
58
|
-
const targetFunctions = !Functions ? [] : Functions.filter(func => {
|
|
59
|
-
if (query.name) {
|
|
60
|
-
const reg = new RegExp(query.name);
|
|
61
|
-
if (func.FunctionName && !func.FunctionName.match(reg))
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
if (query.Runtime)
|
|
65
|
-
return func.Runtime === query.Runtime;
|
|
66
|
-
return true;
|
|
56
|
+
class LambdaFunctionSearch extends core_1.Command {
|
|
57
|
+
async listAllFunctions(client, query = {}, nextMarker, functions = [], totalAmount = 0) {
|
|
58
|
+
const command = new client_lambda_1.ListFunctionsCommand({
|
|
59
|
+
Marker: nextMarker,
|
|
67
60
|
});
|
|
61
|
+
const { NextMarker, Functions } = await client.send(command);
|
|
62
|
+
const targetFunctions = !Functions
|
|
63
|
+
? []
|
|
64
|
+
: Functions.filter((func) => {
|
|
65
|
+
if (query.name) {
|
|
66
|
+
const reg = new RegExp(query.name);
|
|
67
|
+
if (func.FunctionName && !func.FunctionName.match(reg))
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (query.Runtime)
|
|
71
|
+
return func.Runtime === query.Runtime;
|
|
72
|
+
return true;
|
|
73
|
+
});
|
|
68
74
|
const items = functions.concat(targetFunctions);
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
return this.listAllFunctions(query, items);
|
|
75
|
+
const amount = totalAmount + (Functions ? Functions.length : 0);
|
|
76
|
+
if (NextMarker) {
|
|
77
|
+
return this.listAllFunctions(client, query, NextMarker, items, amount);
|
|
72
78
|
}
|
|
73
|
-
return items;
|
|
79
|
+
return { functions: items, amount };
|
|
74
80
|
}
|
|
75
|
-
async getAllRegionFuncs(query,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
async getAllRegionFuncs(query, clientConfig, showAll) {
|
|
82
|
+
// Execute sequentially to avoid race conditions with shared state
|
|
83
|
+
for (const region of regions) {
|
|
84
|
+
await this.worker(query, {
|
|
85
|
+
...clientConfig,
|
|
86
|
+
region,
|
|
87
|
+
}, showAll);
|
|
88
|
+
}
|
|
79
89
|
}
|
|
80
90
|
async run() {
|
|
81
|
-
const { flags } = this.parse(LambdaFunctionSearch);
|
|
82
|
-
const queryBuilder =
|
|
91
|
+
const { flags } = await this.parse(LambdaFunctionSearch);
|
|
92
|
+
const queryBuilder = createQueryBuilder(this.log.bind(this));
|
|
83
93
|
if (flags.runtime)
|
|
84
94
|
queryBuilder.addRuntime(flags.runtime);
|
|
85
95
|
if (flags.search)
|
|
86
96
|
queryBuilder.addSearchQuery(flags.search);
|
|
87
|
-
const
|
|
97
|
+
const clientConfig = {};
|
|
88
98
|
if (!flags.region)
|
|
89
|
-
this.log(chalk_1.default.yellow('warning')
|
|
99
|
+
this.log(`${chalk_1.default.yellow('warning')}: Missing region`);
|
|
90
100
|
if (flags.region) {
|
|
91
|
-
if (flags.region === 'all')
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
if (flags.region === 'all') {
|
|
102
|
+
if (flags.profile)
|
|
103
|
+
clientConfig.profile = flags.profile;
|
|
104
|
+
return this.getAllRegionFuncs(queryBuilder.getQuery(), clientConfig, flags.showAll);
|
|
105
|
+
}
|
|
106
|
+
clientConfig.region = flags.region;
|
|
94
107
|
}
|
|
95
|
-
|
|
108
|
+
if (flags.profile)
|
|
109
|
+
clientConfig.profile = flags.profile;
|
|
110
|
+
return this.worker(queryBuilder.getQuery(), clientConfig, flags.showAll);
|
|
96
111
|
}
|
|
97
|
-
async worker(query,
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
112
|
+
async worker(query, clientConfig, showAll) {
|
|
113
|
+
const config = {};
|
|
114
|
+
if (clientConfig.region)
|
|
115
|
+
config.region = clientConfig.region;
|
|
116
|
+
if (clientConfig.profile) {
|
|
117
|
+
config.credentials = (0, credential_providers_1.fromIni)({ profile: clientConfig.profile });
|
|
103
118
|
}
|
|
119
|
+
const client = new client_lambda_1.LambdaClient(config);
|
|
104
120
|
try {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (flags.showAll)
|
|
121
|
+
const { functions: result, amount } = await this.listAllFunctions(client, query);
|
|
122
|
+
this.log(`=== ${chalk_1.default.green('Matched Functions')}: ${result.length} / ${amount} ===`);
|
|
123
|
+
if (clientConfig.region)
|
|
124
|
+
this.log(`${chalk_1.default.green('Region')} : ${clientConfig.region}`);
|
|
125
|
+
for (const item of result) {
|
|
126
|
+
this.log(item.FunctionName || 'unknown');
|
|
127
|
+
if (showAll)
|
|
113
128
|
console.log(item);
|
|
114
|
-
}
|
|
129
|
+
}
|
|
115
130
|
}
|
|
116
131
|
catch (e) {
|
|
117
|
-
this.error(chalk_1.default.red(e));
|
|
132
|
+
this.error(chalk_1.default.red(String(e)));
|
|
118
133
|
this.exit(1);
|
|
119
134
|
}
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
137
|
LambdaFunctionSearch.description = 'Search Lambda functions';
|
|
138
|
+
LambdaFunctionSearch.examples = [
|
|
139
|
+
'<%= config.bin %> --region us-east-1',
|
|
140
|
+
'<%= config.bin %> --region all',
|
|
141
|
+
'<%= config.bin %> --region us-east-1 --runtime nodejs20.x',
|
|
142
|
+
'<%= config.bin %> --region us-east-1 --search myfunction',
|
|
143
|
+
];
|
|
123
144
|
LambdaFunctionSearch.flags = {
|
|
124
|
-
help:
|
|
145
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
125
146
|
// runtime
|
|
126
|
-
runtime:
|
|
147
|
+
runtime: core_1.Flags.string({
|
|
127
148
|
char: 'R',
|
|
128
149
|
description: [
|
|
129
150
|
'Lambda runtime',
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
].join(', ')
|
|
147
|
-
].join('\n')
|
|
151
|
+
`Example: ${[
|
|
152
|
+
'nodejs18.x',
|
|
153
|
+
'nodejs20.x',
|
|
154
|
+
'nodejs22.x',
|
|
155
|
+
'python3.11',
|
|
156
|
+
'python3.12',
|
|
157
|
+
'python3.13',
|
|
158
|
+
'java11',
|
|
159
|
+
'java17',
|
|
160
|
+
'java21',
|
|
161
|
+
'dotnet6',
|
|
162
|
+
'dotnet8',
|
|
163
|
+
'ruby3.2',
|
|
164
|
+
'ruby3.3',
|
|
165
|
+
'provided.al2',
|
|
166
|
+
'provided.al2023',
|
|
167
|
+
].join(', ')}`,
|
|
168
|
+
].join('\n'),
|
|
148
169
|
}),
|
|
149
170
|
// [For AWS SDK] region
|
|
150
|
-
region:
|
|
171
|
+
region: core_1.Flags.string({
|
|
151
172
|
char: 'r',
|
|
152
|
-
description: 'region, (If you set "all", list all regions)'
|
|
173
|
+
description: 'region, (If you set "all", list all regions)',
|
|
153
174
|
}),
|
|
154
175
|
// [For AWS SDK] profile
|
|
155
|
-
profile:
|
|
176
|
+
profile: core_1.Flags.string({
|
|
156
177
|
char: 'p',
|
|
157
|
-
description: 'AWS CLI profile'
|
|
178
|
+
description: 'AWS CLI profile',
|
|
158
179
|
}),
|
|
159
|
-
search:
|
|
180
|
+
search: core_1.Flags.string({
|
|
160
181
|
char: 's',
|
|
161
|
-
description: 'search by name'
|
|
182
|
+
description: 'search by name',
|
|
162
183
|
}),
|
|
163
|
-
showAll:
|
|
184
|
+
showAll: core_1.Flags.boolean({
|
|
164
185
|
char: 'A',
|
|
165
186
|
description: 'Show all function data',
|
|
166
|
-
default: false
|
|
187
|
+
default: false,
|
|
167
188
|
}),
|
|
168
189
|
};
|
|
169
190
|
module.exports = LambdaFunctionSearch;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lambda-function-search",
|
|
3
3
|
"description": "Search your Lambda functions",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"author": "Hidetaka Okamoto <info@wp-kyoto.net> (https://wp-kyoto.net)",
|
|
6
6
|
"bin": {
|
|
7
7
|
"lambda-function-search": "./bin/run",
|
|
@@ -9,24 +9,21 @@
|
|
|
9
9
|
},
|
|
10
10
|
"bugs": "https://github.com/hideokamoto/lambda-function-search/issues",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@
|
|
13
|
-
"@
|
|
14
|
-
"@oclif/
|
|
15
|
-
"
|
|
16
|
-
"tslib": "^
|
|
12
|
+
"@aws-sdk/client-lambda": "^3.710.0",
|
|
13
|
+
"@aws-sdk/credential-providers": "^3.932.0",
|
|
14
|
+
"@oclif/core": "^4.0.0",
|
|
15
|
+
"chalk": "^4.1.2",
|
|
16
|
+
"tslib": "^2.8.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@types/
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"ts-node": "^7",
|
|
25
|
-
"tslint": "^5",
|
|
26
|
-
"typescript": "^3.0"
|
|
19
|
+
"@biomejs/biome": "^1.9.4",
|
|
20
|
+
"@types/node": "^18.19.0",
|
|
21
|
+
"np": "^10.0.0",
|
|
22
|
+
"ts-node": "^10.9.2",
|
|
23
|
+
"typescript": "^5.7.3"
|
|
27
24
|
},
|
|
28
25
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
26
|
+
"node": ">=18.0.0"
|
|
30
27
|
},
|
|
31
28
|
"files": [
|
|
32
29
|
"/bin",
|
|
@@ -38,16 +35,30 @@
|
|
|
38
35
|
"cli"
|
|
39
36
|
],
|
|
40
37
|
"license": "MIT",
|
|
41
|
-
"main": "lib/index.js",
|
|
42
38
|
"oclif": {
|
|
43
|
-
"bin": "lambda-function-search"
|
|
39
|
+
"bin": "lambda-function-search",
|
|
40
|
+
"commands": {
|
|
41
|
+
"strategy": "single",
|
|
42
|
+
"target": "./lib/index.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/hideokamoto/lambda-function-search.git"
|
|
44
48
|
},
|
|
45
|
-
"repository": "hideokamoto/lambda-function-search",
|
|
46
49
|
"scripts": {
|
|
47
|
-
"
|
|
48
|
-
"prepack": "
|
|
49
|
-
"
|
|
50
|
-
"
|
|
50
|
+
"build": "rm -rf lib && tsc",
|
|
51
|
+
"prepack": "npm run build",
|
|
52
|
+
"lint": "biome lint .",
|
|
53
|
+
"lint:fix": "biome lint --write .",
|
|
54
|
+
"format": "biome format --write .",
|
|
55
|
+
"format:check": "biome format .",
|
|
56
|
+
"check": "biome check .",
|
|
57
|
+
"check:fix": "biome check --write .",
|
|
58
|
+
"posttest": "pnpm run lint && tsc -p . --noEmit",
|
|
59
|
+
"release": "np",
|
|
60
|
+
"test": "echo \"No tests yet\"",
|
|
61
|
+
"typecheck": "tsc -p . --noEmit"
|
|
51
62
|
},
|
|
52
|
-
"
|
|
63
|
+
"packageManager": "pnpm@10.34.9"
|
|
53
64
|
}
|