How can I get environment properties to show up in my Elastic Beanstalk environment when I log in to an Amazon EC2 instance?

Last updated: 2019-06-04

I set environment properties for my AWS Elastic Beanstalk environment. But 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, I don't see these properties.

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 Scripts and the get-config examples.

Resolution

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 AWS 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, 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 AWS 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 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.


Did this article help you?

Anything we could improve?


Need more help?