{"id":17167902,"url":"https://github.com/jacob-meacham/serverless-plugin-deploy-environment","last_synced_at":"2025-04-13T15:35:34.650Z","repository":{"id":44949284,"uuid":"97662231","full_name":"jacob-meacham/serverless-plugin-deploy-environment","owner":"jacob-meacham","description":":zap: Serverless plugin that exposes per-stage deployment variables and deployment environment, and allows users to run commands with the environment of a given stage. The defined deployment environment is automatically merged with the serverless provider environment. It also optionally resolves credstash variables.","archived":false,"fork":false,"pushed_at":"2023-02-03T14:21:11.000Z","size":3665,"stargazers_count":20,"open_issues_count":10,"forks_count":5,"subscribers_count":6,"default_branch":"develop","last_synced_at":"2025-04-08T18:52:44.291Z","etag":null,"topics":["aws","aws-lambda","serverless","serverless-framework","serverless-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacob-meacham.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-19T02:06:46.000Z","updated_at":"2023-11-28T17:20:13.000Z","dependencies_parsed_at":"2023-02-15T04:46:34.566Z","dependency_job_id":null,"html_url":"https://github.com/jacob-meacham/serverless-plugin-deploy-environment","commit_stats":null,"previous_names":["dopplerlabs/serverless-plugin-deploy-environment"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-meacham%2Fserverless-plugin-deploy-environment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-meacham%2Fserverless-plugin-deploy-environment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-meacham%2Fserverless-plugin-deploy-environment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-meacham%2Fserverless-plugin-deploy-environment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacob-meacham","download_url":"https://codeload.github.com/jacob-meacham/serverless-plugin-deploy-environment/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248737146,"owners_count":21153715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","serverless","serverless-framework","serverless-plugin"],"created_at":"2024-10-14T23:10:23.925Z","updated_at":"2025-04-13T15:35:34.630Z","avatar_url":"https://github.com/jacob-meacham.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serverless-plugin-deploy-environment\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n[![Coverage Status](https://coveralls.io/repos/github/DopplerLabs/serverless-plugin-deploy-environment/badge.svg?branch=develop)](https://coveralls.io/github/DopplerLabs/serverless-plugin-deploy-environment?branch=develop)\n![Build Status](https://github.com/jacob-meacham/serverless-plugin-deploy-environment/actions/workflows/ci.yml/badge.svg)\n\nThis plugin exposes per-stage deployment variables and deployment environment, and allows users to run commands with the environment of a given stage. The defined deployment environment is automatically merged with the serverless provider environment. It also optionally resolves [credstash](https://github.com/fugue/credstash) variables. The benefit of this is that its simpler to manage different variables for each environment, and makes the addition of default environment variables simple.\n\nSee our [docs](https://jemonjam.com/serverless-plugin-deploy-environment ) for full documentation.\n\n# Usage\n## Basic Usage\n```yaml\nprovider:\n  region: us-west-2\ncustom:\n  deploy:\n    variables:\n      dev:\n        role: \"devRole\"\n        streamArn: \"devStream\"\n      staging:\n        role: \"stagingRole\"\n        streamArn: \"stagingStream\"\n    environments:\n      # These will be added to all environments\n      default:\n        LAMBDA_LOG_LEVEL: info\n        LAMBDA_REGION: ${self:provider.region} # All references are resolved\n        LAMBDA_ES_HOST:\n          'Fn::GetAtt': [ 'ESCluster', 'DomainEndpoint' ]\n      dev:\n        LAMBDA_ES_HOST: localhost\n\nplugins:\n  - serverless-plugin-deploy-environment\n```\n\nGiven this config, running with `sls deploy --stage dev` would yield the following resolved configuration\n```yaml\ndeployVariables:\n  role: \"devRole\"\n  streamArn: \"devStream\"\ndeployEnvironment:\n  LAMBDA_LOG_LEVEL: info\n  LAMBDA_REGION: us-west-2\n  LAMBDA_ES_HOST: localhost\n```\n\n## Running in an Environment\nThis plugin also exposes a command to run with the stage environment exposed. Give the above config, the command\n`sls runWithEnvironment --command 'echo $LAMBDA_ES_HOST' --stage 'dev'` will output `localhost`.\n\n## Production Usage\nThe way that we use this at Doppler is that we have two separate configuration files at config/deploy.yml and config/variables.yml. All of the variables defined in deploy.yml will become environment variables, and everything in variables.yml are internal variables used to resolve references elsewhere in serverless.yml. Then, in our main serverless.yml file, we have\n\n```yaml\ncustom:\n  deploy:\n    variables: ${file(config/variables.yml)}\n    environments: ${file(config/deploy.yml)}\n\nprovider:\n  # ... Other static properties\n  domain: ${self:deployVariables.domain}\n  role: ${self:deployVariables.role}\n```\n\n# Credstash\nThis plugin also offers the ability to resolve credstash secrets anywhere in the Serverless configuration. First, set up credstash by following the instructions [here](https://github.com/fugue/credstash). Then, in your configuration file, you can add:\n\n```yaml\ncustom:\n  deploy:\n    environments:\n      staging:\n        MY_PASSWORD: ${credstash:stagingPassword}\n      production:\n        MY_PASSWORD: ${credstash:productionPassword}\n\n\n```\n\nPlease note that because these are resolved at build time, the plain-text passwords WILL be viewable in Cloudformation and on the Lambda dashboard.\n\n# Version History\n* 2.1.0\n  - Fix merge mutation issue (Thanks @onhate!)\n* 2.0.2\n  - Fix CLI warning (Thanks @onhate!)\n* 2.0.1\n  - Dependency security updates\n* 2.0.0\n  - Require a more modern version of node and remove the old babel runtime dependency.\n* 1.2.0\n  - Allow default stage population for variables (Thanks @FluxAugur!)\n* 1.1.0\n  - Change invocation target, to play nicely with other offline plugins (like serverless-offline-sns)\n* 1.0.3\n  - Fix packaging issue\n* 1.0.2\n  - Bump version of credstash to deal with change in API (Thanks @concon121)\n* 1.0.1\n  - Fix publishing issue\n* 1.0.0\n  - Initial release\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacob-meacham%2Fserverless-plugin-deploy-environment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacob-meacham%2Fserverless-plugin-deploy-environment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacob-meacham%2Fserverless-plugin-deploy-environment/lists"}