Alex
Alex

Reputation: 2518

AWS - Elastic Beanstalk: Environment variable cannot be removed - reverts to previous value

We're running multiple ELB environments on the Puma with Ruby stack. We've recently reached the 4096 Bytes limit for environment variables. Therefore I tried to remove some legacy env variables in order to release some space for new environment variables.

However, it seems I am only able to update the value of the variables. E.g. I can change MY_SECRET=secret to just MY_SECRET=a, which is then reflected on all instances. If I try to remove it completely, the value is then reverted to the previous one (MY_SECRET=secret - not a).

I tried to remove them via the web UI and also via the eb cli tool (eb setenv MY_SECRET=). Both claim to have finished successfully, but the environment variable is not removed. It behaves the same for different environment variables.

Has anybody an idea of why this is happening?

Thanks in Advance

Upvotes: 0

Views: 1474

Answers (2)

Tiago Fael Matos
Tiago Fael Matos

Reputation: 2077

I had this exact same issue. The solution was to use AWS CLI, but not by using --options-to-remove. That yielded the same result as using eb setenv or the AWS Console UI directly. Instead set the value of the option to null, like:

aws elasticbeanstalk update-environment
  --environment-name <env_name>
  --option-settings
    Namespace=aws:elasticbeanstalk:application:environment,OptionName=MY_SECRET,Value=null

This finally sorted out my problem and hope it sorts out anyone else's hitting this wall.

Upvotes: 0

progfan
progfan

Reputation: 2526

When you say eb setenv MY_SECRET= did not yield any success, do you mean that it just errored out? If so, I recommend that you try eb setenv 'MY_SECRET='. In your unsuccessful attempt, the "=" was not handled by Bash (or whichever shell you are on) as you expected. I have been able to verify that my approach works.

Upvotes: 1

Related Questions