question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow explicitly specifying `serverless.yml` file in CLI options or env var

See original GitHub issue

This is a (Feature Proposal)

Description

For bug reports:

  • What went wrong?
  • What did you expect should have happened?
  • What was the config you used?
  • What stacktrace or error message from your provider did you see?

For feature proposals:

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.

I’d like to make different deployments in dev/stage/prod environments, and I need to include or exclude certain config blocks conditionally in serverless.yml, which is not supported by now.

Instead of implementing conditional logic into serverless.yml, a simpler way is to allow the CLI accepts an explicit ‘-f’ option, or an env var, then we could put different configs in serverless.dev.yml and serverless.prod.yml, etc.

Or even better, the main serverless.yml file is always taken and user could specify extra config files to be merged with the main config, like how docker-compose -f works.

  • If there is additional config how would it look

Similar or dependent issues: None

Additional Data

  • Serverless Framework Version you’re using: 1.24.1
  • Operating System:
  • Stack Trace:
  • Provider Error messages:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:27
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

44reactions
johnwongapicommented, Dec 3, 2018

We should have a command like sls deploy --file serverless-foo.yml

22reactions
HyperBraincommented, Nov 16, 2017

Hi @ccll , thanks for the question/idea.

Having dynamic yaml imports based on the stage should be possible already by using the variable system.

custom:
  stage: ${opt:stage, self:provider.stage}
  config: ${file(serverless.${self:custom:stage}.yml):config}
resources:
  Resources: ${file(serverless.${self:custom:stage}.yml):Resources}
  # This means to fetch the Resources property from the external yaml file

You also could retrieve any value from the environment if you want to make the imports dependent on these with ${env:xxxxxx} as variable reference.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Variables - Serverless Framework
To reference environment variables, use the ${env:SOME_VAR} syntax in your serverless.yml configuration file. It is valid to use the empty string in place ......
Read more >
AWS Lambda Guide - Serverless.yml Reference
The serverless package or serverless deploy commands package the code of all functions into zip files. These zip files are then used for...
Read more >
Resolution of environment variables - Serverless Framework
If stage is not explicitly defined, it defaults to dev . Variable expansion. It is possible to define environment variables as a combination...
Read more >
Serverless Framework Deprecations
The serverless.yml setting is ineffective for deprecations reported before the ... An alternative to free-form CLI options is to use environment variables.
Read more >
Serverless Framework Commands - AWS Lambda - Deploy
Run this command when you have made infrastructure changes (i.e., you edited serverless.yml ). Use serverless deploy function -f myFunction when you have ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found