lambda-live-debugger 0.0.107 → 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/README.md CHANGED
@@ -41,6 +41,11 @@ The tool attaches Lambda Extensions (via a Layer), intercepts, and relays calls
41
41
 
42
42
  ![Architecture](./architecture.drawio.png)
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:
Binary file
@@ -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 findExistingLayer(layerName) {
67
- const listLayerVersionsCommand = new ListLayerVersionsCommand({
68
- LayerName: layerName,
69
- });
70
- const response = await getLambdaClient().send(listLayerVersionsCommand);
71
- if (response.LayerVersions && response.LayerVersions.length > 0) {
72
- const latestLayer = response.LayerVersions[0];
73
- Logger.verbose(`Latest layer version: ${latestLayer.Version}, description: ${latestLayer.Description}`);
74
- return latestLayer;
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
- let layerZipPathFullPath = path.resolve(path.join(getModuleDirname(), "./extension/extension.zip"));
86
- Logger.verbose(`Layer ZIP path: ${layerZipPathFullPath}`);
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}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-live-debugger",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "type": "module",
5
5
  "description": "Debug Lambda functions locally like it is running in the cloud",
6
6
  "repository": {