Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding the keyword used to get the handler in the lambda function defintion #533

Open
alexandre-snr opened this issue Apr 23, 2024 · 1 comment · May be fixed by #546
Open

Overriding the keyword used to get the handler in the lambda function defintion #533

alexandre-snr opened this issue Apr 23, 2024 · 1 comment · May be fixed by #546
Labels
enhancement New feature or request

Comments

@alexandre-snr
Copy link

Is your feature request related to a problem? Please describe.
We are trying to setup Datadog in our serverless project. We are also using serverless-esbuild. An issue we are encountering is in src/helper.ts on line 68:

const { handler } = func;

The keyword handler is used to get the entrypoint to give to esbuild. However with Datadog, this handler is overidden by /opt/nodejs/node_modules/datadog-lambda-js/handler.handler and the real handler is located in the environment:

DD_LAMBDA_HANDLER: 'handler.main'

This is throwing us the following error:

Error: Compilation failed for function alias XX. Please ensure you have an index file with ext .ts or .js, or have a path listed as main key in package.json
    at /Users/XX/XX/XX/node_modules/serverless-esbuild/src/helper.ts:98:13

Describe the solution you'd like
We would like serverless-esbuild to work with Datadog, we can see the following idea:

Allow an other keyword to be used: (could be hardcoded or defined in the custom part of the serverless file?)

{
  handler: '/opt/nodejs/node_modules/datadog-lambda-js/handler.handler',
  esbuildEntrypoint: `${pathResolver(__dirname)}/handler.main`,
}
const { handler, esbuildEntrypoint } = func;
const entryPoint = esbuildEntrypoint || handler;

Describe alternatives you've considered
Maybe there is already a way to achieve what we are trying to do here? Did we miss it?

Additional context
If indeed there is no way to achieve what we are doing, we would be pleased to work on a pull request if you think this could be useful for others

@alexandre-snr alexandre-snr added the enhancement New feature or request label Apr 23, 2024
@alexandre-snr
Copy link
Author

@floydspace What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant