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.

Environment variables removed when deploying

See original GitHub issue

Description

Deploying clears a previously set environment variable.

  • I am using an env.yml but it does not contain a section for environment variables

I have tried:

  • specifying the env var on the create step using --envvar, but this seems to have no effect, no env var is made
  • adding an env var to env.yml and then trying to get it overridden during create using --envvar, again, the parameter has no effect, and the value in env.yml gets set

Why don’t I simply just put my env var details into env.yml if that is working? Because I create and deploy both a staging and a production environment for each module, and I need to set a different value for the env var.

Why don’t I simply script a deploy followed by a setenv and call it a day? Because this results in downtime!

Steps to reproduce

  1. eb create --modules priority-score-calculator --env-group-suffix staging
  2. cd priority-score-calculator
  3. eb setenv NODE_ENV=staging -e priority-score-staging
  4. cd ..
  5. eb deploy --modules priority-score-calculator --env-group-suffix staging

Observed result

The env var set through setenv gets blitzed by the deploy command.

Expected result

Tthe env var set through setenv is not modified by the deploy

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac
  2. EB CLI - installed via brew: EB CLI 3.17.0 (Python 3.8.1)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
halcarletoncommented, Feb 26, 2020

Ok, I was able to reproduce the issue. If I am understanding correctly, you do not define any environment properties in your env.yml, but you do define option settings. It appears that the Elastic Beanstalk service is removing your environment variables, which means this is not an EB CLI bug. I would recommend reporting this on the AWS Elastic Beanstalk forum.

You should be able to reproduce the issue with the awscli by running the following command instead of eb deploy in your repro steps:

aws elasticbeanstalk compose-environments --application-name <application_name> --group-name <group_name> --version-labels <latest_appliction_version_label>

A workaround you could try in the meantime is to define your option settings in .ebextensions instead of in your env.yml. More info on that here.


Closing this issue as it isn’t specific to EB CLI.

0reactions
jcw-commented, Feb 27, 2020

If I am understanding correctly, you do not define any environment properties in your env.yml, but you do define option settings.

Correct - thanks for narrowing it down, I’ll submit an issue on the other forum.

Also thanks for the option settings in .ebextensions tip, I’ll try that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why are my environment variables replaced during Serverless ...
CloudFormation doesn't provide a way to indicate which: existing variables should be removed. existing variables should be replace.
Read more >
Environmental Variables are getting removed on each app ...
Hey, so I'm having some issues keeping my env variables. When I update my app.yaml file: doctl apps update $APPID --spec .do/app.yaml.
Read more >
Environment variable is not removing during uninstall - ITNinja
Hi, When you are adding Environment variable in package or if it is already there in vendor MSI, check in Name column of...
Read more >
Solved: Deployment of environment variables
Solved: Hello, I'm trying the usage of the new environment variables and ... I created the current value within the solution and did...
Read more >
Remove environment variables from a deployment when they ...
OpenShift (and probably k8s, too) updates a deployment's existing environment variables and creates new ones when they were changed ...
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