I set environment properties for my AWS Elastic Beanstalk environment. I don't see these properties when I log in to an Amazon Elastic Compute Cloud (Amazon EC2) instance in my Elastic Beanstalk environment and then run the command to list the environment variables in the shell.
Short description
Environment properties aren't automatically exported to the shell (except for in stacks running PHP), even though they are present in the instance. Instead, environment properties are made available to the application through the stack that it runs in, based on the platform that you're using. To view and set environment properties, you can use the Elastic Beanstalk console or the eb setenv command in the Elastic Beanstalk Command Line Interface (EB CLI).
The Resolution section shows you how to set the source for environment properties in several platforms. For information on additional platform-specific options, see Environment properties and other software settings. For information on how to access environment properties outside your code, see Platform script tools.
Resolution
Important: The following resolutions apply only to Amazon Linux Amazon Machine Images (AMIs). For Amazon Linux 2 instances, see How do I use environment variables from an Elastic Beanstalk instance shell?
Python
Environment properties are written to the /opt/python/current/env file, which is sourced into the virtualenv stack where the application runs. For more information, see Using the Elastic Beanstalk Python platform.
To set the source, log in to the instance, and then run the following command:
~$ source /opt/python/current/env
Ruby
Environment properties are first written to a JSON file (/opt/elasticbeanstalk/deploy/configuration/containerconfiguration) that contains all the stack configuration information. If the predeployment hook at /opt/elasticbeanstalk/hooks/configdeploy/pre/10_setup_envvars.sh is triggered, then the opt/elasticbeanstalk/support/envvars file is populated with all the environment properties. The opt/elasticbeanstalk/support/envvars file is then sourced by the stack to make the environment variables available to the application. For more information, see Using the Elastic Beanstalk Ruby platform.
To set the source, log in to the instance, and then run the following command:
source /opt/elasticbeanstalk/support/envvars
Java
Environment properties that you set at launch don't become shell environment variables. For more information, see Configuring your Java SE environment.
Windows
Environment properties are passed from C:\Program Files\Amazon\ElasticBeanstalk\config\containerconfiguration to the Microsoft Internet Information Services (IIS) server.