Skip to content

Commit

Permalink
fix(stacks): disable condition
Browse files Browse the repository at this point in the history
  • Loading branch information
FabrizioCafolla committed Oct 3, 2023
1 parent b6981ab commit 3b64d62
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/constructs/aws-lambda/newrelic-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ export function addNewRelicLayer(scope: Construct, lambdaFunction: lambda.Functi

export class NewRelicFunction extends Function {
constructor(scope: Construct, id: string, props: FunctionNewRelicProps) {
const app_handler = props.handler;
const handler = 'newrelic_lambda_wrapper.handler';
const disableNewRelic = props.disableNewRelic ?? false;

super(scope, id, { ...props, handler });
if (disableNewRelic === true) {
super(scope, id, props);
} else {
const app_handler = props.handler;
const handler = 'newrelic_lambda_wrapper.handler';

const disableNewRelic = props.disableNewRelic ?? false;
super(scope, id, { ...props, handler });

if (disableNewRelic === false) {
this.addNewRelicLayer(scope, {
handler: app_handler,
newRelicLayerName: props.newRelicLayerName,
Expand All @@ -82,6 +84,7 @@ export class NewRelicFunction extends Function {
newRelicwithExtensionSendLogs: props.newRelicwithExtensionSendLogs ?? true,
});
}

}

addNewRelicLayer(scope: Construct, props: NewRelicLayerProps) {
Expand All @@ -91,14 +94,16 @@ export class NewRelicFunction extends Function {

export class NewRelicFunctionNode extends FunctionNode {
constructor(scope: Construct, id: string, props: FunctionNodeNewRelicProps) {
const app_handler = props.handler ?? 'index.handler';
const handler = 'newrelic-lambda-wrapper.handler';
const disableNewRelic = props.disableNewRelic ?? false;

super(scope, id, { ...props, handler });
if (disableNewRelic === true) {
super(scope, id, props);
} else {
const app_handler = props.handler ?? 'index.handler';
const handler = 'newrelic-lambda-wrapper.handler';

const disableNewRelic = props.disableNewRelic ?? false;
super(scope, id, { ...props, handler });

if (disableNewRelic === false) {
this.addNewRelicLayer(scope, {
handler: app_handler,
newRelicLayerName: props.newRelicLayerName,
Expand Down

0 comments on commit 3b64d62

Please sign in to comment.