Reputation:
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?
Upvotes: 10
Views: 4257
Reputation: 11069
export VARNAME="my value"
Check with:
printenv VARNAME
Upvotes: 0
Reputation: 3157
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.
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.
Upvotes: 4
Reputation:
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
Upvotes: 14