Is there any way to change the handler path for a ...
# sst
l
Is there any way to change the handler path for a function post-build. My use case is configuring the New Relic Lambda Extension. This extension expects the function handler to be a method defined in the layer, called
newrelic-lambda-wrapper.handler
. But I cannot set this in my stack code (like in this SAM example), as SST will try to do this and fail:
Copy code
Building Lambda function newrelic-lambda-wrapper.handler

Error: Cannot find a handler file for "newrelic-lambda-wrapper.handler".
t
I can't think of a work around for this right now hm
How does it know which function to call? Do you have to set an env variable?
f
From looking at the SAM example, it seems to take the
NEW_RELIC_LAMBDA_HANDLER
en var
This should work
Copy code
this.getAllFunctions().forEach(fn => {
  const cfnFunction = fn.node.defaultChild;
  fn.addEnvironment("NEW_RELIC_LAMBDA_HANDLER", cfnFunction.handler);
  cfnFunction.handler = "app.lambdaHandler";
});
t
ah you can mutate it after, interesting
l
Oh wow - just tried this and it worked perfectly. Thank you @Frank!!