Photo by on Caspar Camille Rubin Unsplash , a framework for managing cloud applications, is a very powerful tool. As your application grows in complexity, it can be difficult to manage deployment variables based on different stages (development, QA, production). Currently it isn’t easy to reference deployment specific custom or environment variables. I knew there had to be a better way of handling these variables while also making them composable. After some research into serverless’ architecture, I came up with a plugin that does just that: . Serverless [serverless-plugin-composed-vars](https://github.com/chris-feist/serverless-plugin-composed-vars) What does it do? lets you define stage specific variable files. It overrides the variables defined in your or in separate and files for custom and environment variables respectively. To define stage specific files, just insert the stage name into the file like so: or . For example, if you’d like to create variable files for your stage named “prod”, you’d name the files and . [serverless-plugin-composed-vars](https://github.com/chris-feist/serverless-plugin-composed-vars) serverless.yml variables.yml environment.yml variables.stage.yml environment.stage.yml variables.prod.yml environment.prod.yml Let’s see it in action: Using the example files above, custom and environment variables are composed and computed into the following for a “prod” deployment stage: custom:googlesWebsite: www.google.commyEndpoint: api.endpoint.com environment:THE_ANSWER_IS: 42USER_TABLE_NAME: UsersMY_ENDPOINT: api.endpoint.com For a cleaner service file, you can separate your default variables into their own and files. will automatically read those files when composing your deployment variables. Note that the file variables have the least priority when also using default variable files. serverless.yml variables.yml environment.yml [serverless-plugin-composed-vars](https://github.com/chris-feist/serverless-plugin-composed-vars) serverless.yml How do I use it? Install Install the plugin using your favorite package manager: npm install -D serverless-plugin-composed-vars or yarn add -D serverless-plugin-composed-vars Enable Add the plugin to your service file: # serverless.yml plugins: serverless-plugin-composed-vars other-serverless-plugin : To ensure compatibility with other plugins, it is recommended that be the first plugin in the plugins list. Note [serverless-plugin-composed-vars](https://github.com/chris-feist/serverless-plugin-composed-vars) Create Create deployment stage variable files. The default file names are and for custom and environment variables. Here’s an example project structure for custom variables: variables.stage.yml environment.stage.yml Advanced Usage For advanced usage and configuration, see the . GitHub Readme How does it work? Under the covers, leverages the fact that serverless doesn’t compute variables . This allows the plugin to compose deployment stage variables and rewrite them before your service is packaged for deployment. [serverless-plugin-composed-vars](https://github.com/chris-feist/serverless-plugin-composed-vars) until hooks are executed Check it out! Now that you’ve seen how easy it is to use deployment stage variables, give the plugin a shot. Leave any comments or suggestions here or submit issues on the repository. GitHub