From 0f2f1334bdcad5c1b8cb15a27612f9b7d187a72b Mon Sep 17 00:00:00 2001 From: RWSalexjarvis <83243028+RWSalexjarvis@users.noreply.github.com> Date: Mon, 11 Dec 2023 21:31:11 -0700 Subject: [PATCH 1/2] add layer to the server-level `layers` object when `defaultLambdaInsights` is `true` --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index b91ade8..b47bc6a 100644 --- a/index.js +++ b/index.js @@ -145,6 +145,12 @@ class AddLambdaInsights { } try { + if (customLambdaInsights && customLambdaInsights.defaultLambdaInsights) { + const layerARN = await this.generateLayerARN(layerVersion); + this.provider.layers = this.provider.layers || []; + this.provider.layers.push(layerARN) + } + let policyToggle = false; const functions = Object.keys(this.service.functions); for (const functionName of functions) { From 6e455926aec846374fccc201545618a63b5f1547 Mon Sep 17 00:00:00 2001 From: RWSalexjarvis <83243028+RWSalexjarvis@users.noreply.github.com> Date: Mon, 11 Dec 2023 21:40:36 -0700 Subject: [PATCH 2/2] add the policy if any function requires it --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index b47bc6a..e5f1b1c 100644 --- a/index.js +++ b/index.js @@ -144,14 +144,15 @@ class AddLambdaInsights { return; } try { + let policyToggle = false; - if (customLambdaInsights && customLambdaInsights.defaultLambdaInsights) { + if (globalLambdaInsights) { const layerARN = await this.generateLayerARN(layerVersion); this.provider.layers = this.provider.layers || []; - this.provider.layers.push(layerARN) + this.provider.layers.push(layerARN); + policyToggle = true; } - - let policyToggle = false; + const functions = Object.keys(this.service.functions); for (const functionName of functions) { const fn = this.service.functions[functionName];