A plugin is custom JavaScript code that extends Serverless with new features.
If you or your organization have a specific workflow, install a pre-written plugin or write one to customize Serverless to your needs.
Since Serverless is a group of "core" plugins, custom plugins are written exactly the same way as core plugins. Learn more about creating a custom plugin.
Security note: Plugins are JavaScript code that Serverless loads and executes. Treat configured plugins, local plugin paths, and
plugins.localPathas trusted code. Do not run Serverless commands against untrusted projects, templates, or pull requests that configure plugins.
Install only plugins from sources you trust.
Plugins are installed per service. They are not applied globally.
To install a plugin, run the following command in a service directory:
serverless plugin install -n custom-serverless-plugin
This command will install the plugin via NPM and register it in serverless.yml.
You can also install the plugin manually via NPM:
npm install --save-dev custom-serverless-plugin
and then register it in serverless.yml in the plugins section:
# serverless.yml file
plugins:
- custom-serverless-pluginSome plugins require extra configuration. The custom section in serverless.yml is where you can add extra configuration for plugins (the plugin's documentation will tell you if you need to add anything there):
plugins:
- custom-serverless-plugin
custom:
customkey: customvalueNote for plugin authors: read Extending the configuration to learn how to enhance serverless.yml with configuration validation.
AWS plugin authors should use AWS SDK v3 clients directly and obtain
Serverless-resolved client configuration with provider.getAwsSdkV3Config().
See AWS SDK v3 clients for details.
Only helpers documented in the plugin guides are considered supported for
plugin authors. Avoid importing files from the framework's internal lib/**
tree.
If you are working on a plugin, or have a plugin that is just designed for one project, it can be loaded from local files:
plugins:
- ./local-directory/custom-serverless-pluginThe path must start with ./ and is relative to the root of your service.
The legacy object form can also set plugins.localPath to change where non-relative plugin names are loaded from. Use plugins.localPath only with trusted directories.
Keep in mind that the order you define your plugins matters. Serverless loads all the core plugins, and then the custom plugins in the order you've defined them.
# serverless.yml
plugins:
- plugin1
- plugin2In this case plugin1 is loaded before plugin2.