Stack Config Plugin for Serverless
A serverless plugin to manage configurations for a micro-service stack.
Features
-
outputs
- This downloads this service's outputs to a file in /PROJECT_ROOT/.serverless/stack-outputs.json and updates the config file in S3. -
outputs download
- This downloads the existing, combined, stack config file from S3.
Install
npm install --save serverless-plugin-stack-config
Usage
Add the plugin to your serverless.yml
like the following:
NOTE: The script
and backup
properties are optional.
serverless.yml:
provider:...plugins: - serverless-plugin-stack-configcustom: stack-config: script: scripts/transform.js backup: s3: key: config/stack-config.json bucket: ${self:service}-${opt:env} shallow: truefunctions:...resources:...
Configure the Stack Output
You can now supply a script that you can use to transform the stack outputs before they are saved to file.
For example you could rename outputs or create new ones from the values received.
// scripts/transform.jsmodule.exports = async function transform(serverless, stackOutputs) { // rename stackOutputs.TrackingServiceEndpoint = stackOutputs.ServiceEndpoint; // delete delete stackOutputs.ServerlessDeploymentBucketName; delete stackOutputs.ServiceEndpoint; // return updated stack return stackOutputs;}
Example shell commands:
serverless outputs --stage dev --region eu-west-1serverless outputs download --stage dev --region eu-west-1# with save directory locationserverless outputs download --stage dev --region eu-west-1 --path .
Limitations
If you are deploying several applications at the same time, there is the possibility that some data loss could occur in the event that multiple stacks are updating the config file in S3.
License
MIT