Skip to content

Commit

Permalink
feat: added support for layer-provided lambda handlers
Browse files Browse the repository at this point in the history
refs #548
  • Loading branch information
kirrg001 committed Aug 16, 2022
1 parent 5f8bbc8 commit 0acd9b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ custom:
includeModules: false # Node modules configuration for packaging
packager: 'npm' # Packager that will be used to package your external modules
excludeFiles: src/**/*.test.js # Provide a glob for files to ignore
lambdaEntrypoint: null # Provide a custom lambda entrypoint. Useful when using layer provided handlers.
```

### Webpack configuration file
Expand Down
7 changes: 6 additions & 1 deletion lib/Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const DefaultConfig = {
packagerOptions: {},
keepOutputDirectory: false,
config: null,
concurrency: os.cpus().length
concurrency: os.cpus().length,
lambdaEntrypoint: null
};

class Configuration {
Expand Down Expand Up @@ -82,6 +83,10 @@ class Configuration {
return this._config.packagerOptions;
}

get lambdaEntrypoint() {
return this._config.lambdaEntrypoint;
}

get config() {
return this._config.config;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ module.exports = {
const getHandlerFileAndFunctionName = functionDefinition => {
const { handler: handlerProp, image: imageProp } = functionDefinition;

// CASE: lambda handler is inside lambda layer. Define custom entrypoint
// alternative solution is to read require('./package.json').main
if (this.configuration.lambdaEntrypoint) return this.configuration.lambdaEntrypoint;

if (handlerProp) {
return handlerProp;
}
Expand Down

0 comments on commit 0acd9b4

Please sign in to comment.