lambda-live-debugger 0.0.106 → 0.0.108
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/.husky/pre-commit +1 -0
- package/.prettierignore +6 -0
- package/.prettierrc +1 -0
- package/LICENSE.md +24 -27
- package/README.md +25 -12
- package/dist/cloudFormation.mjs +2 -2
- package/dist/configuration/getConfigFromCliArgs.mjs +1 -4
- package/dist/configuration/getConfigFromTsConfigFile.mjs +1 -1
- package/dist/configuration/getConfigFromWizard.mjs +0 -1
- package/dist/extension/extension.zip +0 -0
- package/dist/extension/nodejs/node_modules/interceptor.js +52 -47
- package/dist/extension/nodejs/node_modules/interceptor.js.map +2 -2
- package/dist/fileWatcher.mjs +1 -1
- package/dist/frameworks/cdkFramework.mjs +3 -3
- package/dist/frameworks/cdkFrameworkWorker.mjs +3 -2
- package/dist/frameworks/samFramework.mjs +11 -11
- package/dist/frameworks/slsFramework.mjs +40 -40
- package/dist/frameworks/terraformFramework.d.ts +1 -2
- package/dist/frameworks/terraformFramework.mjs +7 -6
- package/dist/gitignore.mjs +2 -2
- package/dist/infraDeploy.mjs +50 -40
- package/dist/lldebugger.mjs +3 -2
- package/dist/nodeEsBuild.mjs +3 -3
- package/dist/nodeHandler.mjs +2 -2
- package/dist/nodeWorker.mjs +2 -2
- package/dist/nodeWorkerRunner.mjs +7 -6
- package/dist/resourceDiscovery.mjs +1 -1
- package/dist/vsCode.d.ts +1 -2
- package/dist/vsCode.mjs +6 -6
- package/eslint.config.js +43 -0
- package/fix-imports.js +4 -2
- package/package.json +13 -2
- package/tsconfig.build.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm run typecheck && npm run prettier && npm run lint
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/LICENSE.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
thereof.
|
|
25
25
|
|
|
26
26
|
1.5. “Incompatible With Secondary Licenses”
|
|
27
|
-
|
|
27
|
+
means
|
|
28
28
|
|
|
29
29
|
a. that the initial Contributor has attached the notice described in
|
|
30
30
|
Exhibit B to the Covered Software; or
|
|
@@ -89,7 +89,6 @@
|
|
|
89
89
|
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
|
90
90
|
outstanding shares or beneficial ownership of such entity.
|
|
91
91
|
|
|
92
|
-
|
|
93
92
|
2. License Grants and Conditions
|
|
94
93
|
|
|
95
94
|
2.1. Grants
|
|
@@ -157,7 +156,6 @@
|
|
|
157
156
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
|
158
157
|
Section 2.1.
|
|
159
158
|
|
|
160
|
-
|
|
161
159
|
3. Responsibilities
|
|
162
160
|
|
|
163
161
|
3.1. Distribution of Source Form
|
|
@@ -232,29 +230,29 @@
|
|
|
232
230
|
5. Termination
|
|
233
231
|
|
|
234
232
|
5.1. The rights granted under this License will terminate automatically if You
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
233
|
+
fail to comply with any of its terms. However, if You become compliant,
|
|
234
|
+
then the rights granted under this License from a particular Contributor
|
|
235
|
+
are reinstated (a) provisionally, unless and until such Contributor
|
|
236
|
+
explicitly and finally terminates Your grants, and (b) on an ongoing basis,
|
|
237
|
+
if such Contributor fails to notify You of the non-compliance by some
|
|
238
|
+
reasonable means prior to 60 days after You have come back into compliance.
|
|
239
|
+
Moreover, Your grants from a particular Contributor are reinstated on an
|
|
240
|
+
ongoing basis if such Contributor notifies You of the non-compliance by
|
|
241
|
+
some reasonable means, this is the first time You have received notice of
|
|
242
|
+
non-compliance with this License from such Contributor, and You become
|
|
243
|
+
compliant prior to 30 days after Your receipt of the notice.
|
|
246
244
|
|
|
247
245
|
5.2. If You initiate litigation against any entity by asserting a patent
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
246
|
+
infringement claim (excluding declaratory judgment actions, counter-claims,
|
|
247
|
+
and cross-claims) alleging that a Contributor Version directly or
|
|
248
|
+
indirectly infringes any patent, then the rights granted to You by any and
|
|
249
|
+
all Contributors for the Covered Software under Section 2.1 of this License
|
|
250
|
+
shall terminate.
|
|
253
251
|
|
|
254
252
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
253
|
+
license agreements (excluding distributors and resellers) which have been
|
|
254
|
+
validly granted by You or Your distributors under this License prior to
|
|
255
|
+
termination shall survive termination.
|
|
258
256
|
|
|
259
257
|
6. Disclaimer of Warranty
|
|
260
258
|
|
|
@@ -266,7 +264,7 @@
|
|
|
266
264
|
Should any Covered Software prove defective in any respect, You (not any
|
|
267
265
|
Contributor) assume the cost of any necessary servicing, repair, or
|
|
268
266
|
correction. This disclaimer of warranty constitutes an essential part of this
|
|
269
|
-
License. No use of
|
|
267
|
+
License. No use of any Covered Software is authorized under this License
|
|
270
268
|
except under this disclaimer.
|
|
271
269
|
|
|
272
270
|
7. Limitation of Liability
|
|
@@ -301,7 +299,6 @@
|
|
|
301
299
|
contract shall be construed against the drafter shall not be used to construe
|
|
302
300
|
this License against a Contributor.
|
|
303
301
|
|
|
304
|
-
|
|
305
302
|
10. Versions of the License
|
|
306
303
|
|
|
307
304
|
10.1. New Versions
|
|
@@ -327,9 +324,9 @@
|
|
|
327
324
|
modified license differs from this License).
|
|
328
325
|
|
|
329
326
|
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
327
|
+
If You choose to distribute Source Code Form that is Incompatible With
|
|
328
|
+
Secondary Licenses under the terms of this version of the License, the
|
|
329
|
+
notice described in Exhibit B of this License must be attached.
|
|
333
330
|
|
|
334
331
|
Exhibit A - Source Code Form License Notice
|
|
335
332
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
Lambda Live Debugger is an indispensable tool for debugging AWS Lambda functions from your computer, even though they are deployed in the cloud. It supports Lambdas written in JavaScript or TypeScript.
|
|
5
|
+
Lambda Live Debugger ([GitHub](https://github.com/ServerlessLife/lambda-live-debugger)) is an indispensable tool for debugging AWS Lambda functions from your computer, even though they are deployed in the cloud. It supports Lambdas written in JavaScript or TypeScript.
|
|
6
6
|
|
|
7
7
|
This tool offers similar functionality to [SST](https://sst.dev/) and [Serverless Framework v4](https://www.serverless.com/blog/serverless-framework-v4-general-availability), with the addition of an Observability Mode.
|
|
8
8
|
|
|
@@ -19,28 +19,38 @@ It supports the following frameworks:
|
|
|
19
19
|
|
|
20
20
|
**This project is in the early alpha stage. Your feedback is incredibly valuable. Please let me know if it works for you or if you encounter any issues. I've tested many scenarios, but people can configure their projects and TypeScript settings in numerous ways. The tool is flexible and can be adjusted to fit your setup in most cases without needing additional features. If you need help, please let me know. Any suggestions for improvements are welcome.**
|
|
21
21
|
|
|
22
|
+
If the tool is working well for you, please fill out the general [FEEDBACK FORM](https://forms.gle/v6ekZtuB45Rv3EyW9). This helps me understand how extensively the tool has been tested and whether there is a general interest in its further development.
|
|
23
|
+
|
|
24
|
+
If you've encountered a bug, need help, or would like to request additional features, please create an issue on [GitHub Issue](https://github.com/ServerlessLife/lambda-live-debugger/issues).
|
|
25
|
+
|
|
22
26
|
Contact me via:
|
|
23
27
|
|
|
28
|
+
- [Feedback Form](https://forms.gle/v6ekZtuB45Rv3EyW9)
|
|
24
29
|
- [GitHub Issues](https://github.com/ServerlessLife/lambda-live-debugger/issues)
|
|
25
30
|
- [LinkedIn](http://www.linkedin.com/in/marko-serverlesslife)
|
|
26
31
|
|
|
27
32
|
## The Problem Statement
|
|
28
33
|
|
|
29
|
-
Serverless is amazing and solves many issues with traditional systems. However, writing code for Lambda functions can be challenging. The cycle of writing, deploying, running, fixing, and redeploying is time-consuming and tedious.
|
|
34
|
+
Serverless is amazing and solves many issues with traditional systems. However, writing code for Lambda functions can be challenging. The cycle of writing, deploying, running, fixing, and redeploying is time-consuming and tedious. You could use tools to run Lambda locally or use unit/integration tests; those approaches often don't replicate the actual environment closely enough.
|
|
30
35
|
|
|
31
36
|
## How It Works
|
|
32
37
|
|
|
33
|
-
Lambda Live Debugger connects to your deployed Lambda, routes requests to your computer, and sends responses back to the Lambda. This allows you to debug locally, but the system behaves as if the code is running in the cloud with the same permissions.
|
|
38
|
+
Lambda Live Debugger connects to your deployed Lambda, routes requests to your computer, and sends responses back to the deployed Lambda. This allows you to debug locally, but the system behaves as if the code is running in the cloud with the same permissions.
|
|
34
39
|
|
|
35
|
-
The tool attaches Lambda Extensions (via a Layer)
|
|
40
|
+
The tool attaches Lambda Extensions (via a Layer), intercepts, and relays calls to AWS IoT. AWS IoT transfers messages between your Lambda and local machine. If the Lambda is written in TypeScript, it's transpiled to JavaScript. The code is executed via the Node Worker Thread.
|
|
36
41
|
|
|
37
42
|

|
|
38
43
|
|
|
44
|
+
AWS keys generated on the cloud for Lambda are transferred to the local environment, so the code has the same permissions as it would executed on the cloud. There could be a difference in packaging, mainly regarding static files, which are probably in different locations. You can use additional environment variables to adjust the code:
|
|
45
|
+
|
|
46
|
+
- `IS_LOCAL = true` = Lambda is executed locally
|
|
47
|
+
- `LOCAL_PROJECT_DIR` = directory of the project
|
|
48
|
+
|
|
39
49
|
### Infrastructure Changes
|
|
40
50
|
|
|
41
51
|
Lambda Live Debugger makes the following changes to your AWS infrastructure:
|
|
42
52
|
|
|
43
|
-
-
|
|
53
|
+
- Deploys Lambda Layer
|
|
44
54
|
- Attaches the Layer to each Lambda you're debugging
|
|
45
55
|
- Adds a policy to the Lambda Role for AWS IoT access
|
|
46
56
|
|
|
@@ -71,7 +81,7 @@ _(On Linux and Mac: `sudo npm install lambda-live-debugger -g`)_
|
|
|
71
81
|
or locally
|
|
72
82
|
|
|
73
83
|
```
|
|
74
|
-
npm install lambda-live-debugger
|
|
84
|
+
npm install lambda-live-debugger
|
|
75
85
|
```
|
|
76
86
|
|
|
77
87
|
_(If installed locally, you must prefix all commands with `npx`, if they are not part of `scripts` in `package.json`.)_
|
|
@@ -116,7 +126,7 @@ The configuration is saved to `lldebugger.config.ts`.
|
|
|
116
126
|
|
|
117
127
|
## Configuration file lldebugger.config.ts
|
|
118
128
|
|
|
119
|
-
Example lldebugger.config.ts
|
|
129
|
+
Example `lldebugger.config.ts`:
|
|
120
130
|
|
|
121
131
|
```typescript
|
|
122
132
|
import { type LldConfigTs } from "lambda-live-debugger";
|
|
@@ -138,10 +148,12 @@ The setting are the same as for CLI parameters.
|
|
|
138
148
|
|
|
139
149
|
### Custom framework implementation and adjustment
|
|
140
150
|
|
|
151
|
+
```typescript
|
|
141
152
|
getLambdas: async (foundLambdas) => {
|
|
142
153
|
//you can customize the list of lambdas here or create your own
|
|
143
154
|
//return foundLambdas;
|
|
144
155
|
},
|
|
156
|
+
```
|
|
145
157
|
|
|
146
158
|
### Debugging
|
|
147
159
|
|
|
@@ -209,18 +221,19 @@ I am not a Terraform developer, so I only know the basics. Please provide a samp
|
|
|
209
221
|
|
|
210
222
|
## Know issues
|
|
211
223
|
|
|
212
|
-
|
|
224
|
+
Check the [GitHub issues](https://github.com/ServerlessLife/lambda-live-debugger/issues).
|
|
213
225
|
|
|
214
226
|
## Missing Features
|
|
215
227
|
|
|
216
|
-
Check the [
|
|
228
|
+
Check the [GitHub issues](https://github.com/ServerlessLife/lambda-live-debugger/issues). The biggest missing feature right now is MFA authentication and more Terraform configurations.
|
|
217
229
|
|
|
218
230
|
## Reporting an Issue
|
|
219
231
|
|
|
220
|
-
- Make sure the bug hasn't already been reported.
|
|
221
|
-
- Use descriptive titles with prefixes like "bug:", "help:", "feature:", or "discussion:".
|
|
232
|
+
- Make sure the bug hasn't already been reported. If you fount if, add a "+1" comment so I know there are multiple users struggling with the same issue. If possible, add some additional info.
|
|
233
|
+
- Use descriptive titles with prefixes like "bug:", "help:", "feature:", or "discussion:".
|
|
222
234
|
- Enable verbose logging and provide the full log.
|
|
223
235
|
- Describe your setup in detail, or better yet, provide a sample project.
|
|
236
|
+
- Specify exact framework version (CDK, SLS, SAM ...) and exact version of Lambda Live Debugger version.
|
|
224
237
|
|
|
225
238
|
## Authors:
|
|
226
239
|
|
|
@@ -229,7 +242,7 @@ Check the [open issues](https://github.com/ServerlessLife/lambda-live-debugger/i
|
|
|
229
242
|
|
|
230
243
|
## Contributors (alphabetical)
|
|
231
244
|
|
|
232
|
-
- ⭐ Your name here for
|
|
245
|
+
- ⭐ Your name here for documentation contributions, minor code additions, or sample projects submitted with bug reports.
|
|
233
246
|
|
|
234
247
|
## Declarment
|
|
235
248
|
|
package/dist/cloudFormation.mjs
CHANGED
|
@@ -76,12 +76,12 @@ async function getCloudFormationResources(stackName, awsConfiguration) {
|
|
|
76
76
|
async function getLambdasInStack(stackName, awsConfiguration) {
|
|
77
77
|
const response = await getCloudFormationResources(stackName, awsConfiguration);
|
|
78
78
|
const lambdaResources = response.StackResourceSummaries?.filter((resource) => resource.ResourceType === "AWS::Lambda::Function");
|
|
79
|
-
return lambdaResources?.map((resource) => {
|
|
79
|
+
return (lambdaResources?.map((resource) => {
|
|
80
80
|
return {
|
|
81
81
|
lambdaName: resource.PhysicalResourceId,
|
|
82
82
|
logicalId: resource.LogicalResourceId,
|
|
83
83
|
};
|
|
84
|
-
});
|
|
84
|
+
}) ?? []);
|
|
85
85
|
}
|
|
86
86
|
export const CloudFormation = {
|
|
87
87
|
getCloudFormationStackTemplate,
|
|
@@ -11,10 +11,7 @@ export async function getConfigFromCliArgs(supportedFrameworks = []) {
|
|
|
11
11
|
const version = await getVersion();
|
|
12
12
|
const program = new Command();
|
|
13
13
|
program.name("lld").description("Lambda Live Debugger").version(version);
|
|
14
|
-
program.option("-r, --remove [option]", "Remove Lambda Live Debugger infrastructure. Options: 'keep-layer' (default), 'remove-all'. The latest also removes the Lambda Layer"
|
|
15
|
-
//validateRemoveOption,
|
|
16
|
-
//"keep-layer"
|
|
17
|
-
);
|
|
14
|
+
program.option("-r, --remove [option]", "Remove Lambda Live Debugger infrastructure. Options: 'keep-layer' (default), 'remove-all'. The latest also removes the Lambda Layer");
|
|
18
15
|
program.option("-w, --wizard", "Program interactively asks for each parameter and saves it to lldebugger.config.ts");
|
|
19
16
|
program.option("-v, --verbose", "Verbose logs");
|
|
20
17
|
program.option("-c, --context <context>", "AWS CDK context", (value, previous) => previous.concat(value), []);
|
|
@@ -89,7 +89,6 @@ export async function getConfigFromWizard({ configFromCliArgs, supportedFramewor
|
|
|
89
89
|
]);
|
|
90
90
|
answers = { ...answers, ...samAnswers };
|
|
91
91
|
}
|
|
92
|
-
answers.framework === currentFramework ? undefined : answers.framework;
|
|
93
92
|
// monorepo subfolder
|
|
94
93
|
const answersSubfolder = await inquirer.prompt([
|
|
95
94
|
{
|
|
Binary file
|
|
@@ -49727,57 +49727,62 @@ async function handler(event, context) {
|
|
|
49727
49727
|
}
|
|
49728
49728
|
}
|
|
49729
49729
|
async function regularMode(context, event) {
|
|
49730
|
-
|
|
49731
|
-
|
|
49732
|
-
|
|
49733
|
-
|
|
49734
|
-
|
|
49735
|
-
|
|
49736
|
-
|
|
49737
|
-
|
|
49738
|
-
|
|
49739
|
-
|
|
49740
|
-
|
|
49741
|
-
|
|
49742
|
-
|
|
49743
|
-
|
|
49744
|
-
|
|
49745
|
-
|
|
49746
|
-
if (
|
|
49747
|
-
|
|
49748
|
-
|
|
49749
|
-
}
|
|
49750
|
-
}
|
|
49751
|
-
if (message.type === "SUCCESS") {
|
|
49752
|
-
resolve(message.data.body);
|
|
49730
|
+
let promiseResolve;
|
|
49731
|
+
let promiseReject;
|
|
49732
|
+
const promise = new Promise((resolve, reject) => {
|
|
49733
|
+
promiseResolve = resolve;
|
|
49734
|
+
promiseReject = reject;
|
|
49735
|
+
});
|
|
49736
|
+
const timeout = setTimeout(() => {
|
|
49737
|
+
promiseResolve({
|
|
49738
|
+
statusCode: 500,
|
|
49739
|
+
body: "The function's in live debug mode but it hasn't heard back from your machine yet. If this is the first time you're trying out Lambda Live Debugger on this AWS account, AWS might need around 10 minutes to get everything ready. Hang tight and check back in a bit!"
|
|
49740
|
+
});
|
|
49741
|
+
}, 5 * 1e3);
|
|
49742
|
+
const ioTService = await IoTService.connect({
|
|
49743
|
+
onMessage: async (message) => {
|
|
49744
|
+
Logger.log("IoT message", message);
|
|
49745
|
+
if (message.type === "PING") {
|
|
49746
|
+
if (message.data.workerId === workerId) {
|
|
49747
|
+
Logger.log("Pinged by the debugger");
|
|
49748
|
+
clearTimeout(timeout);
|
|
49753
49749
|
}
|
|
49754
|
-
|
|
49755
|
-
|
|
49756
|
-
|
|
49757
|
-
|
|
49750
|
+
}
|
|
49751
|
+
if (["SUCCESS", "ERROR"].includes(message.type)) {
|
|
49752
|
+
if (message.data.workerId === workerId) {
|
|
49753
|
+
clearTimeout(timeout);
|
|
49758
49754
|
}
|
|
49759
|
-
},
|
|
49760
|
-
topic
|
|
49761
|
-
});
|
|
49762
|
-
const payload = {
|
|
49763
|
-
type: "INVOKE",
|
|
49764
|
-
data: {
|
|
49765
|
-
workerId,
|
|
49766
|
-
requestId: context.awsRequestId,
|
|
49767
|
-
functionId: process.env.LLD_FUNCTION_ID,
|
|
49768
|
-
deadline: context.getRemainingTimeInMillis(),
|
|
49769
|
-
event,
|
|
49770
|
-
context,
|
|
49771
|
-
env: process.env
|
|
49772
49755
|
}
|
|
49773
|
-
|
|
49774
|
-
|
|
49775
|
-
|
|
49776
|
-
|
|
49777
|
-
|
|
49778
|
-
|
|
49779
|
-
|
|
49756
|
+
if (message.type === "SUCCESS") {
|
|
49757
|
+
promiseResolve(message.data.body);
|
|
49758
|
+
}
|
|
49759
|
+
if (message.type === "ERROR") {
|
|
49760
|
+
const error = new Error(message.data.errorMessage);
|
|
49761
|
+
error.stack = message.data.trace;
|
|
49762
|
+
promiseReject(error);
|
|
49763
|
+
}
|
|
49764
|
+
},
|
|
49765
|
+
topic
|
|
49780
49766
|
});
|
|
49767
|
+
const payload = {
|
|
49768
|
+
type: "INVOKE",
|
|
49769
|
+
data: {
|
|
49770
|
+
workerId,
|
|
49771
|
+
requestId: context.awsRequestId,
|
|
49772
|
+
functionId: process.env.LLD_FUNCTION_ID,
|
|
49773
|
+
deadline: context.getRemainingTimeInMillis(),
|
|
49774
|
+
event,
|
|
49775
|
+
context,
|
|
49776
|
+
env: process.env
|
|
49777
|
+
}
|
|
49778
|
+
};
|
|
49779
|
+
Logger.log(
|
|
49780
|
+
"Publishing to IoT",
|
|
49781
|
+
`${process.env.LLD_DEBUGGER_ID}/events`,
|
|
49782
|
+
payload
|
|
49783
|
+
);
|
|
49784
|
+
await ioTService.publish(payload, `${process.env.LLD_DEBUGGER_ID}/events`);
|
|
49785
|
+
return promise;
|
|
49781
49786
|
}
|
|
49782
49787
|
async function observableMode(context, event) {
|
|
49783
49788
|
const regularHandler = async () => {
|