lambda-live-debugger 0.0.92 → 0.0.94
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 +20 -43
- package/dist/configuration/getConfigFromCliArgs.mjs +3 -3
- package/dist/extension/extension.zip +0 -0
- package/dist/extension/nodejs/node_modules/interceptor.js +26 -23
- package/dist/extension/nodejs/node_modules/interceptor.js.map +2 -2
- package/dist/frameworks/cdkFramework.d.ts +0 -11
- package/dist/frameworks/cdkFramework.mjs +30 -19
- package/dist/frameworks/cdkFrameworkWorker.mjs +61 -0
- package/dist/frameworks/slsFramework.mjs +3 -5
- package/dist/index.mjs +4 -4
- package/dist/ioTService.mjs +7 -5
- package/dist/lldebugger.mjs +1 -1
- package/dist/nodeEsBuild.mjs +2 -3
- package/dist/nodeWorkerRunner.mjs +1 -1
- package/fix-imports.js +9 -1
- package/package.json +32 -2
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ It supports the following frameworks:
|
|
|
17
17
|
|
|
18
18
|
## Early Alpha State
|
|
19
19
|
|
|
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
|
|
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
22
|
Contact me via:
|
|
23
23
|
|
|
@@ -26,13 +26,13 @@ Contact me via:
|
|
|
26
26
|
|
|
27
27
|
## The Problem Statement
|
|
28
28
|
|
|
29
|
-
Serverless is amazing and
|
|
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. While local testing tools and unit/integration tests exist, they often don't replicate the actual environment closely enough.
|
|
30
30
|
|
|
31
31
|
## How It Works
|
|
32
32
|
|
|
33
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.
|
|
34
34
|
|
|
35
|
-
The tool attaches Lambda Extensions (via a Layer) to intercept
|
|
35
|
+
The tool attaches Lambda Extensions (via a Layer) to intercept and relay calls to AWS IoT, transferring messages between your Lambda and local machine. If the Lambda is written in TypeScript, it's transpiled to JavaScript. The code is executed via Node Worker Thread.
|
|
36
36
|
|
|
37
37
|

|
|
38
38
|
|
|
@@ -44,37 +44,39 @@ Lambda Live Debugger makes the following changes to your AWS infrastructure:
|
|
|
44
44
|
- Attaches the Layer to each Lambda you're debugging
|
|
45
45
|
- Adds a policy to the Lambda Role for AWS IoT access
|
|
46
46
|
|
|
47
|
-
In case you do not want to debug all functions and add Layer to them, you can limit to the ones you need via `function` parameter.
|
|
47
|
+
In case you do not want to debug all functions and add Layer to them, you can limit to the ones you need via the `function` parameter.
|
|
48
48
|
|
|
49
49
|
The tool generates temporary files in the `.lldebugger` folder, which can be deleted after debugging. The wizard can add `.lldebugger` to `.gitignore` for you.
|
|
50
50
|
|
|
51
51
|
## Development Process
|
|
52
52
|
|
|
53
|
-
Since you deploy code to a real AWS account, it's best to have a dedicated environment only for yourself. It could be your
|
|
53
|
+
Since you deploy code to a real AWS account, it's best to have a dedicated environment only for yourself. It could be your personal environment or an environment created for a feature. That is [common practice when developing serverless systems](https://theburningmonk.com/2019/09/why-you-should-use-temporary-stacks-when-you-do-serverless/). If that's not feasible due to organizational or technical reasons, use Observability Mode.
|
|
54
54
|
|
|
55
55
|
## Observability Mode
|
|
56
56
|
|
|
57
|
-
In Observability Mode, Lambda Live Debugger intercepts requests and sends them to your computer without waiting for a response. The Lambda continues as usual. The response from your machine is ignored. This mode can be used in development, testing, or even, if you are an
|
|
57
|
+
In Observability Mode, Lambda Live Debugger intercepts requests and sends them to your computer without waiting for a response. The Lambda continues as usual. The response from your machine is ignored. This mode can be used in the development, testing, or even, if you are an adventurous, production environment. It samples requests every 3 seconds by default (configurable with an `interval` setting) to avoid overloading the system.
|
|
58
58
|
|
|
59
59
|
## Getting Started
|
|
60
60
|
|
|
61
61
|
### Installation
|
|
62
62
|
|
|
63
|
-
Install
|
|
63
|
+
Install globally:
|
|
64
64
|
|
|
65
65
|
```
|
|
66
|
-
npm install lambda-live-debugger
|
|
66
|
+
npm install lambda-live-debugger -g
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
_(On Linux and Mac: `sudo npm install lambda-live-debugger -g`)_
|
|
70
|
+
|
|
71
|
+
or locally
|
|
70
72
|
|
|
71
73
|
```
|
|
72
74
|
npm install lambda-live-debugger -g
|
|
73
75
|
```
|
|
74
76
|
|
|
75
|
-
(
|
|
77
|
+
_(If installed locally, you must prefix all commands with `npx`, if they are not part of `scripts` in `package.json`.)_
|
|
76
78
|
|
|
77
|
-
Running the Tool
|
|
79
|
+
## Running the Tool
|
|
78
80
|
|
|
79
81
|
With default profile, region, and other default settings:
|
|
80
82
|
|
|
@@ -82,37 +84,24 @@ With default profile, region, and other default settings:
|
|
|
82
84
|
lld
|
|
83
85
|
```
|
|
84
86
|
|
|
85
|
-
or
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
npx lld
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
But you probably need to tweak some settings. You can do it via CLI parameters or, better run a wizard:
|
|
87
|
+
You probably need to tweak some settings. You can do it via CLI parameters or, better, run the wizard:
|
|
92
88
|
|
|
93
89
|
```
|
|
94
90
|
lld -w
|
|
95
91
|
```
|
|
96
92
|
|
|
97
|
-
or if installed locally:
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
npx lld -w
|
|
101
|
-
```
|
|
102
|
-
|
|
103
93
|
The configuration is saved to `lldebugger.config.ts`
|
|
104
94
|
|
|
105
95
|
### CLI Parameters
|
|
106
96
|
|
|
107
97
|
```
|
|
108
98
|
-V, --version output the version number
|
|
109
|
-
-r, --remove [option] Remove Lambda Live Debugger infrastructure. Options: 'keep-layer' (default),
|
|
110
|
-
|
|
111
|
-
-w, --wizard Program interactively asks for each parameter
|
|
99
|
+
-r, --remove [option] Remove Lambda Live Debugger infrastructure. Options: 'keep-layer' (default), 'remove-all'. The latest also removes the Lambda Layer
|
|
100
|
+
-w, --wizard Program interactively asks for each parameter and saves it to lldebugger.config.ts
|
|
112
101
|
-v, --verbose Verbose logs
|
|
113
102
|
-c, --context <context> AWS CDK context (default: [])
|
|
114
103
|
-s, --stage <stage> Serverless Framework stage
|
|
115
|
-
-f, --function <function name> Filter by function name
|
|
104
|
+
-f, --function <function name> Filter by function name. You can use * as a wildcard
|
|
116
105
|
-m, --subfolder <subfolder> Monorepo subfolder
|
|
117
106
|
-o, --observable Observable mode
|
|
118
107
|
-i --interval <interval> Observable mode interval (default: "3000")
|
|
@@ -151,7 +140,7 @@ For other tools, please send documentation to include here. WebStorm instruction
|
|
|
151
140
|
|
|
152
141
|
## Monorepo Setup
|
|
153
142
|
|
|
154
|
-
|
|
143
|
+
Set the `subfolder` parameter if your framework is in a subfolder.
|
|
155
144
|
|
|
156
145
|
## Custom Configuration
|
|
157
146
|
|
|
@@ -168,12 +157,6 @@ To remove Lambda Live Debugger from your AWS account
|
|
|
168
157
|
lld -r
|
|
169
158
|
```
|
|
170
159
|
|
|
171
|
-
or if installed locally:
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
npx lld -r
|
|
175
|
-
```
|
|
176
|
-
|
|
177
160
|
This detaches the Layer from your Lambdas and removes the IoT permission policy. It will not remove the Layer as others might use it.
|
|
178
161
|
|
|
179
162
|
To also remove the Layer:
|
|
@@ -182,12 +165,6 @@ To also remove the Layer:
|
|
|
182
165
|
lld -r=all
|
|
183
166
|
```
|
|
184
167
|
|
|
185
|
-
or if installed locally:
|
|
186
|
-
|
|
187
|
-
```
|
|
188
|
-
npx lld -r=all
|
|
189
|
-
```
|
|
190
|
-
|
|
191
168
|
## Framework-Specific Notes
|
|
192
169
|
|
|
193
170
|
### AWS CDK v2
|
|
@@ -218,8 +195,8 @@ Check the [open issues](https://github.com/ServerlessLife/lambda-live-debugger/i
|
|
|
218
195
|
|
|
219
196
|
## Reporting an Issue
|
|
220
197
|
|
|
221
|
-
- Make sure the bug
|
|
222
|
-
- Use descriptive titles with prefixes like "bug:", "help:", "feature:", or "discussion:". Please also add the matching label and, if needed, set priority via label.
|
|
198
|
+
- Make sure the bug hasn't already been reported. Add a "+1" comment so I know there are multiple users struggling with the same issue. If possible, add some additional info.
|
|
199
|
+
- Use descriptive titles with prefixes like "bug:", "help:", "feature:", or "discussion:". Please also add the matching label and, if needed, set priority via a label.
|
|
223
200
|
- Enable verbose logging and provide the full log.
|
|
224
201
|
- Describe your setup in detail, or better yet, provide a sample project.
|
|
225
202
|
|
|
@@ -11,15 +11,15 @@ 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
|
|
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
15
|
//validateRemoveOption,
|
|
16
16
|
//"keep-layer"
|
|
17
17
|
);
|
|
18
|
-
program.option("-w, --wizard", "Program interactively asks for each parameter and
|
|
18
|
+
program.option("-w, --wizard", "Program interactively asks for each parameter and saves it to lldebugger.config.ts");
|
|
19
19
|
program.option("-v, --verbose", "Verbose logs");
|
|
20
20
|
program.option("-c, --context <context>", "AWS CDK context", (value, previous) => previous.concat(value), []);
|
|
21
21
|
program.option("-s, --stage <stage>", "Serverless Framework stage");
|
|
22
|
-
program.option("-f, --function <function name>", "Filter by function name. You can use * as wildcard");
|
|
22
|
+
program.option("-f, --function <function name>", "Filter by function name. You can use * as a wildcard");
|
|
23
23
|
program.option("-m, --subfolder <subfolder>", "Monorepo subfolder");
|
|
24
24
|
program.option("-o, --observable", "Observable mode");
|
|
25
25
|
program.option("-i --interval <interval>", "Observable mode interval", defaultObservableInterval.toString());
|
|
Binary file
|
|
@@ -49587,6 +49587,26 @@ function splitMessageToChunks(input) {
|
|
|
49587
49587
|
|
|
49588
49588
|
// ../ioTService.ts
|
|
49589
49589
|
var import_client_iot = __toESM(require_dist_cjs55(), 1);
|
|
49590
|
+
|
|
49591
|
+
// ../logger.ts
|
|
49592
|
+
var verboseEnabled = false;
|
|
49593
|
+
function verbose(...args) {
|
|
49594
|
+
if (verboseEnabled) {
|
|
49595
|
+
console.info(...args);
|
|
49596
|
+
}
|
|
49597
|
+
}
|
|
49598
|
+
function setVerbose(enabled) {
|
|
49599
|
+
verboseEnabled = enabled;
|
|
49600
|
+
}
|
|
49601
|
+
var Logger = {
|
|
49602
|
+
log: console.log,
|
|
49603
|
+
error: console.error,
|
|
49604
|
+
warn: console.warn,
|
|
49605
|
+
verbose,
|
|
49606
|
+
setVerbose
|
|
49607
|
+
};
|
|
49608
|
+
|
|
49609
|
+
// ../ioTService.ts
|
|
49590
49610
|
var device2;
|
|
49591
49611
|
var chunks = /* @__PURE__ */ new Map();
|
|
49592
49612
|
async function getIoTEndpoint({
|
|
@@ -49628,20 +49648,20 @@ async function connect(props) {
|
|
|
49628
49648
|
});
|
|
49629
49649
|
if (props?.topic) {
|
|
49630
49650
|
device2.subscribe(props.topic, { qos: 1 });
|
|
49631
|
-
|
|
49651
|
+
Logger.verbose("[IoT] Subscribed to topic ", props.topic);
|
|
49632
49652
|
}
|
|
49633
49653
|
device2.on("connect", () => {
|
|
49634
|
-
|
|
49654
|
+
Logger.verbose("[IoT] Connected");
|
|
49635
49655
|
connectedPromiseResolve();
|
|
49636
49656
|
});
|
|
49637
49657
|
device2.on("error", (err) => {
|
|
49638
|
-
|
|
49658
|
+
Logger.error("[IoT] Error", err);
|
|
49639
49659
|
});
|
|
49640
49660
|
device2.on("close", () => {
|
|
49641
|
-
|
|
49661
|
+
Logger.verbose("[IoT] Closed");
|
|
49642
49662
|
});
|
|
49643
49663
|
device2.on("reconnect", () => {
|
|
49644
|
-
|
|
49664
|
+
Logger.verbose("[IoT] Reconnecting...");
|
|
49645
49665
|
});
|
|
49646
49666
|
if (props?.onMessage) {
|
|
49647
49667
|
const messageReceived = (topic2, buffer) => {
|
|
@@ -49664,6 +49684,7 @@ async function connect(props) {
|
|
|
49664
49684
|
};
|
|
49665
49685
|
device2.on("message", messageReceived);
|
|
49666
49686
|
}
|
|
49687
|
+
await connectedPromise;
|
|
49667
49688
|
return {
|
|
49668
49689
|
publish: async (payload, topic2) => {
|
|
49669
49690
|
await connectedPromise;
|
|
@@ -49688,24 +49709,6 @@ var IoTService = {
|
|
|
49688
49709
|
connect
|
|
49689
49710
|
};
|
|
49690
49711
|
|
|
49691
|
-
// ../logger.ts
|
|
49692
|
-
var verboseEnabled = false;
|
|
49693
|
-
function verbose(...args) {
|
|
49694
|
-
if (verboseEnabled) {
|
|
49695
|
-
console.info(...args);
|
|
49696
|
-
}
|
|
49697
|
-
}
|
|
49698
|
-
function setVerbose(enabled) {
|
|
49699
|
-
verboseEnabled = enabled;
|
|
49700
|
-
}
|
|
49701
|
-
var Logger = {
|
|
49702
|
-
log: console.log,
|
|
49703
|
-
error: console.error,
|
|
49704
|
-
warn: console.warn,
|
|
49705
|
-
verbose,
|
|
49706
|
-
setVerbose
|
|
49707
|
-
};
|
|
49708
|
-
|
|
49709
49712
|
// interceptor.ts
|
|
49710
49713
|
var workerId = import_crypto5.default.randomBytes(16).toString("hex");
|
|
49711
49714
|
var topic = `${process.env.LLD_DEBUGGER_ID}/events/${workerId}`;
|