Serverless Import Config Plugin
Split your serverless.yaml
config file into smaller modules and import them.
By using this plugin you can build your serverless config from smaller parts separated by functionalities.
Imported config is merged, so all keys are supported and lists are concatenated (without duplicates).
Works on importing yaml files by path or node module, especially useful in multi-package repositories.
Installation
Install with npm:
npm install --save-dev serverless-import-config-plugin
And then add the plugin to your serverless.yml
file:
plugins:
- serverless-import-config-plugin
Usage
Specify config files to import in custom.import
list:
custom:
import:
- ./path/to/serverless.yml
- ./path/to/dir
- module-name
- '@myproject/users-api'
- module-name/custom-serverless.yml
custom.import
can be also a string, when only one file needs to be imported:
custom:
import: '@myproject/users-api'
Relative paths
All function handler paths are automatically prefixed by the imported config directory.
functions:
postOrder:
handler: functions/postOrder.handler
For other fields you need to use ${dirname}
variable manually.
${dirname}
points to a directory of imported config file.
custom:
webpack:
webpackConfig: ${dirname}/webpack.config.js
Customizable boilerplates
In case you want to customize imported config in more dynamic way, provide it as javascript file (serverless.js
).
module.exports = ({ name, schema }) => ({
provider: {
iamRoleStatements: [
],
},
})
You can pass arguments to the imported file using module
and inputs
fields:
custom:
import:
- module: '@myproject/aws-dynamodb'
inputs:
name: custom-table
schema: