Elastic Beanstalk custom AMI can't see environment variables
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
The environment variables used by Elastic Beanstalk aren't shell environment variables. They're passed in to your application environment on launch (with different methods used for different languages).
E.g.
Java Environment Variables
PHP Environment Variables
I've solved this one in the past by having a page on the admin side of the app that just lists them for debugging purposes.