Environment variables in Elastic beanstalk not updating after cloning an environment

0

Hello,

I cloned an elastic beanstalk environment and tried either through the web console as well as the AWS CLI to change the environment variables, but changes seem to be ignored in some way as the instances have the new values I set, but in the console interface as well using AWS CLI, they show the previous values of the environment variables, like there were no changes at all. This is not supposed to work like this.

Let me give some context...

  • The environment I cloned uses platform PHP 7.4 running on 64bit Amazon Linux 2/3.5.8, which is a retired platform, just in case this can be in some way one of the causes of the issue.
  • After running command aws elasticbeanstalk describe-configuration-settings --application-name my-app --environment-name my-app-new-env, I get a configuration setting I am not sure if can be related with the issue it shows the environment variables I tried to change but is not working:
                {
                    "Namespace": "aws:cloudformation:template:parameter",
                    "OptionName": "EnvironmentVariables",
                    "Value": "APP_ENV=testing,DB_PORT=3306,MORE_VARIABLES_LIKE_THIS=withSomeOldValue,COMPOSER_HOME=/root,APP_MAINTENANCE=0,PRUEBA=1"
                },
  • I even tried deleting the current configuration settings with command aws elasticbeanstalk delete-environment-configuration --application-name my-app --environment-name my-app-new-env, but the issue remains there

A full example of the situation is: I had on the original environment the variables APP_ENV=testing and APP_MAINTENANCE=0, which are copied to the new environment. Let's say I didn't have a variable called TEST1, if I modify either by AWSCLI or AWS Console the env variable APP_ENV to production, remove APP_MAINTENANCE and add TEST1=value, the following happens:

  • Connecting to one of the EC2 instances of the environment and running command /opt/elasticbeanstalk/bin/get-config environment shows correctly APP_ENV=production and TEST1=value and doesn't show APP_MAINTENANCE, so everything seem to be fine
  • Into the Elastic Beanstalk console, environment variables remain in the original state so APP_ENV=testing, APP_MAINTENANCE still present with value 0, but TEST1=value is added to the list
asked 3 months ago189 views
1 Answer
0

If you want to remove an option setting, you should use the --options-to-remove argument

aws elasticbeanstalk update-environment --options-to-remove "Namespace=aws:cloudformation:template:parameter,OptionName=EnvironmentVariables"

See https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-configuration-methods-after.html#configuration-options-remove-awscli

AWS
progfan
answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions