Skip to content

Commit

Permalink
fix: custom provider layers missing with esbuild (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
mzl-md authored May 17, 2023
1 parent 8dc75bc commit 43e7d0e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ class LumigoPlugin {

for (const func of functions) {
const funcRuntime = func.runtime || runtime;
func.layers = func.layers || [];
func.layers = func.layers || [
...(this.serverless.service.provider.layers || [])
];
const layer = await this.getLayerArn(funcRuntime);
func.layers.push(layer);
func.environment = func.environment || {};
Expand Down
17 changes: 17 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,23 @@ describe("Lumigo plugin (node.js)", () => {

assertNodejsFunctionsHaveLayers();
});

test("custom layers configured at provider level are retained", async () => {
serverless.service.provider.layers = ["custom-layer"];

await lumigo.afterCreateDeploymentArtifacts();

console.log(serverless.service.functions);
const wrappedFunction = serverless.service.functions.hello;
expect(wrappedFunction.layers).not.toBeUndefined();
expect(wrappedFunction.layers).toHaveLength(2);
expect(wrappedFunction.layers[0]).toEqual("custom-layer");
expect(wrappedFunction.layers[1]).toEqual(
expect.stringMatching(
/arn:aws:lambda:us-east-1:114300393969:layer:lumigo-node-tracer:\d+/
)
);
});
});

describe("when useLayers is true", () => {
Expand Down

0 comments on commit 43e7d0e

Please sign in to comment.