lambda-live-debugger 0.0.107 → 0.0.109
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 +9 -2
- package/dist/configuration.mjs +7 -1
- package/dist/extension/extension.zip +0 -0
- package/dist/infraDeploy.mjs +38 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,12 +35,17 @@ Serverless is amazing and solves many issues with traditional systems. However,
|
|
|
35
35
|
|
|
36
36
|
## How It Works
|
|
37
37
|
|
|
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.
|
|
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. In case of code changes, you do not have to redeploy. The code is reloaded automatically without deploying or even restarting the debugger.
|
|
39
39
|
|
|
40
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.
|
|
41
41
|
|
|
42
42
|

|
|
43
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
|
+
|
|
44
49
|
### Infrastructure Changes
|
|
45
50
|
|
|
46
51
|
Lambda Live Debugger makes the following changes to your AWS infrastructure:
|
|
@@ -172,6 +177,8 @@ You might want to configure your development tool for debugging. The wizard auto
|
|
|
172
177
|
}
|
|
173
178
|
```
|
|
174
179
|
|
|
180
|
+
Now, you have to press F5 or press Run -> Start Debugging, and you can set breakpoints, step through lines of code, inspect variables... For more information on how to [debug in VSCode, please refer to this link](https://code.visualstudio.com/docs/editor/debugging).
|
|
181
|
+
|
|
175
182
|
For other tools, please send documentation to include here. WebStorm instructions are especially needed.
|
|
176
183
|
|
|
177
184
|
## Monorepo Setup
|
|
@@ -224,7 +231,7 @@ Check the [GitHub issues](https://github.com/ServerlessLife/lambda-live-debugger
|
|
|
224
231
|
|
|
225
232
|
## Reporting an Issue
|
|
226
233
|
|
|
227
|
-
- Make sure the bug hasn't already been reported. If you fount
|
|
234
|
+
- Make sure the bug hasn't already been reported. If you fount it has been, add a "+1" comment so I know there are multiple users struggling with the same issue. If possible, add some additional info.
|
|
228
235
|
- Use descriptive titles with prefixes like "bug:", "help:", "feature:", or "discussion:".
|
|
229
236
|
- Enable verbose logging and provide the full log.
|
|
230
237
|
- Describe your setup in detail, or better yet, provide a sample project.
|
package/dist/configuration.mjs
CHANGED
|
@@ -43,7 +43,13 @@ async function readConfig() {
|
|
|
43
43
|
delete configFromCliArgs[key];
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
const configMerged = {
|
|
46
|
+
const configMerged = {
|
|
47
|
+
...configFromConfigFile,
|
|
48
|
+
...configFromCliArgs,
|
|
49
|
+
context: configFromCliArgs.context && configFromCliArgs.context?.length > 0
|
|
50
|
+
? configFromCliArgs.context
|
|
51
|
+
: configFromConfigFile?.context,
|
|
52
|
+
};
|
|
47
53
|
const debuggerId = await generateDebuggerId(!!configMerged.observable);
|
|
48
54
|
setConfig({
|
|
49
55
|
...configMerged,
|
|
Binary file
|
package/dist/infraDeploy.mjs
CHANGED
|
@@ -61,18 +61,26 @@ function getIAMClient() {
|
|
|
61
61
|
/**
|
|
62
62
|
* Find an existing layer
|
|
63
63
|
* @param layerName
|
|
64
|
+
* @param description
|
|
64
65
|
* @returns
|
|
65
66
|
*/
|
|
66
|
-
async function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
async function findExistingLayerVersion(layerName, description) {
|
|
68
|
+
let nextMarker;
|
|
69
|
+
do {
|
|
70
|
+
const listLayerVersionsCommand = new ListLayerVersionsCommand({
|
|
71
|
+
LayerName: layerName,
|
|
72
|
+
Marker: nextMarker,
|
|
73
|
+
});
|
|
74
|
+
const response = await getLambdaClient().send(listLayerVersionsCommand);
|
|
75
|
+
if (response.LayerVersions && response.LayerVersions.length > 0) {
|
|
76
|
+
const matchingLayer = response.LayerVersions.find((layer) => layer.Description === description);
|
|
77
|
+
if (matchingLayer) {
|
|
78
|
+
Logger.verbose(`Matching layer version: ${matchingLayer.Version}, description: ${matchingLayer.Description}`);
|
|
79
|
+
return matchingLayer;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
nextMarker = response.NextMarker;
|
|
83
|
+
} while (nextMarker);
|
|
76
84
|
Logger.verbose("No existing layer found.");
|
|
77
85
|
return undefined;
|
|
78
86
|
}
|
|
@@ -82,24 +90,8 @@ async function findExistingLayer(layerName) {
|
|
|
82
90
|
*/
|
|
83
91
|
async function deployLayer() {
|
|
84
92
|
const layerDescription = `Lambda Live Debugger Layer version ${await getVersion()}`;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// check if file exists
|
|
88
|
-
try {
|
|
89
|
-
await fs.access(layerZipPathFullPath);
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
// if I am debugging
|
|
93
|
-
const layerZipPathFullPath2 = path.join(getModuleDirname(), "../dist/extension/extension.zip");
|
|
94
|
-
try {
|
|
95
|
-
await fs.access(layerZipPathFullPath2);
|
|
96
|
-
layerZipPathFullPath = layerZipPathFullPath2;
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
throw new Error(`File for the layer not found: ${layerZipPathFullPath}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
const existingLayer = await findExistingLayer(layerName);
|
|
93
|
+
// Check if the layer already exists
|
|
94
|
+
const existingLayer = await findExistingLayerVersion(layerName, layerDescription);
|
|
103
95
|
if (existingLayer &&
|
|
104
96
|
existingLayer.LayerVersionArn &&
|
|
105
97
|
existingLayer.Description === layerDescription // check if the layer version is already deployed
|
|
@@ -118,6 +110,24 @@ async function deployLayer() {
|
|
|
118
110
|
return existingLayer.LayerVersionArn;
|
|
119
111
|
}
|
|
120
112
|
}
|
|
113
|
+
// check the ZIP
|
|
114
|
+
let layerZipPathFullPath = path.resolve(path.join(getModuleDirname(), "./extension/extension.zip"));
|
|
115
|
+
// get the full path to the ZIP file
|
|
116
|
+
try {
|
|
117
|
+
await fs.access(layerZipPathFullPath);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// if I am debugging
|
|
121
|
+
const layerZipPathFullPath2 = path.join(getModuleDirname(), "../dist/extension/extension.zip");
|
|
122
|
+
try {
|
|
123
|
+
await fs.access(layerZipPathFullPath2);
|
|
124
|
+
layerZipPathFullPath = layerZipPathFullPath2;
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
throw new Error(`File for the layer not found: ${layerZipPathFullPath}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
Logger.verbose(`Layer ZIP path: ${layerZipPathFullPath}`);
|
|
121
131
|
// Read the ZIP file containing your layer code
|
|
122
132
|
const layerContent = await fs.readFile(layerZipPathFullPath);
|
|
123
133
|
Logger.verbose(`Deploying ${layerDescription}`);
|