Register function names with AWS SSM Parameter Store
Requirements:
- Serverless v1.12.x or higher.
- AWS provider
This plugin creates an SSM Parameter with your functions' fully qualified Lambda Function names as values. The main motivation for this plugin is to remove the dependency that any client code would have on the AWS Stack, as the stack name is part of the fully qualified Lambda Function name. Using this plugin, it is easier to move functions between stacks with out less changes to client code and configuration.
One caveat is the fact that any IAM policies that are written for these functions will still need to be updated. In the case of Serverless configuration, if you use the built-in SSM Parameter resolution, then it might be as simple as just redeploying any client upstream services.
Install via npm in the root of your Serverless service:
npm install serverless-plugin-registry --save-dev
- Add the plugin to the
plugins
array in your Serverlessserverless.yml
:
plugins:
- serverless-plugin-registry
service: ServerlessPluginRegistry
provider:
stage: ${opt:stage, "Test"}
functions:
Hello:
handler: hello.js
This will produce an SSM Parameter with
- Name: /ServerlessPluginRegistry/Test/Hello/FunctionName
- Value: ServerlessPluginRegistry-Test-Hello
service: ServerlessPluginRegistry
provider:
stage: ${opt:stage, "Test"}
custom:
registry:
baseName: /Registry/${self:provider.stage}
functions:
Hello:
handler: hello.js
This will produce an SSM Parameter with
- Name: /Registry/Test/Hello/FunctionName
- Value: ServerlessPluginRegistry-Test-Hello
service: ServerlessPluginRegistry
provider:
stage: ${opt:stage, "Test"}
functions:
Hello:
handler: hello.js
registry:
baseName: /Registry/${self:provider.stage}
This will produce an SSM Parameter with
- Name: /Registry/Test/Hello/FunctionName
- Value: ServerlessPluginRegistry-Test-Hello
service: ServerlessPluginRegistry
provider:
stage: ${opt:stage, "Test"}
functions:
Hello:
handler: hello.js
registry:
baseName: /Registry/${self:provider.stage}
HowAreYou:
handler: howAreYou.js
registry:
register: true
Goodbye:
handler: goodbye.js
This will only produce two SSM Parameters with
-
Name: /Registry/Test/Hello/FunctionName
-
Value: ServerlessPluginRegistry-Test-Hello
-
Name: /ServerlessPluginRegistry/Test/HowAreYou/FunctionName
-
Value: ServerlessPluginRegistry-Test-HowAreYou
Help us making this plugin better and future proof.
- Clone the code
- Install the dependencies with
npm install
- Create a feature branch
git checkout -b new_feature
- Lint with standard
npm run lint
This software is released under the MIT license. See the license file for more details.