Custom AMI with elastic beans cannot see environment variables

I use custom AMI for Elastic Beanstalk because of some big package requirements.

When I SSH into EC2 instance, none of my environment variables (specified in the Elastic Beanstalk web console settings) are available for my application.

My production application can easily access variables, but I cannot do this in the console, which really makes debugging difficult.

How to make all environment variables available when I use the SSH console?

+6
source share
2 answers

Found an easy way to load all environment variables by looking at the Elastic Beanstalk support forums:

. /opt/python/current/env 

To view the variable: echo ${VAR_NAME} or printenv VAR_NAME , which does not work before using the above command. ( UNIX, get the environment variable )

Bonus:

To simply view a list of variables: printenv

List variables as export: cat /opt/python/current/env

To add export to the end of the configuration file: cat /opt/python/current/env >> /path/to/my/file

+9
source

The environment variables used by Elastic Beanstalk are not shell variables. They are transferred to your application environment at startup (with various methods used for different languages).

eg.

Java environment variables

PHP environment variables

I solved this in the past, having a page on the admin side of the application that simply lists them for debugging purposes.

+5
source

Source: https://habr.com/ru/post/971728/


All Articles