Elastic Beanstalk custom AMI can't see environment variables

amazon-ec2, amazon-elastic-beanstalk, amazon-web-services, ssh

Solution

Found an easy way to load all the environment variables while perusing the Elastic Beanstalk support forums:

. /opt/python/current/env

To view a variable: `echo ${VAR_NAME}` or `printenv VAR_NAME`, which doesn't work before using the above command. (UNIX, get environment variable)

Bonus:

To simply view a list of the variables: `printenv`

To list the variables as exports: `cat /opt/python/current/env`

To add the exports to the end of a config file: `cat /opt/python/current/env >> /path/to/my/file`

Problem

I'm using a custom AMI for Elastic Beanstalk because of some large package requirements. When I SSH into the EC2 instance none of my environment variables (specified in the Elastic Beanstalk web console settings) are available to my app. My app in production can access the variables just fine, but I cannot do so in the console, which is really making debugging anything very difficult. How do I make all of the environment variables available when I'm using the SSH console?

Original source

Related problems