11👍
Try running the command /opt/elasticbeanstalk/bin/get-config environment
after you ssh into the EC2 instance.
17👍
During deployment, the environment properties are readily available to your .platform
hook scripts.
After deployment, e.g. when using eb ssh
, you need to load the environment properties manually.
One option is to use the EB get-config tool. The environment properties can be accessed either individually (using the -k
option), or as a JSON or YAML object with key-value pairs.
For example, one way to export
all environment properties would be:
export $(/opt/elasticbeanstalk/bin/get-config --output YAML environment |
sed -r 's/: /=/' | xargs)
Here the get-config
part returns all environment properties as YAML, the sed
part replaces the ': '
in the YAML output with '='
, and the xargs
part fixes quoted numbers.
Note this does not require sudo
.
Alternatively, you could refer to this AWS knowledge center post:
Important: On Amazon Linux 2, all environment properties are centralized into a single file called
/opt/elasticbeanstalk/deployment/env
. You must use this file during Elastic Beanstalk’s application deployment process only. …
The post describes how to make a copy of the env
file during deployment, using .platform
hooks, and how to set permissions so you can access the file later.
You can also perform similar steps manually, using SSH. Once you have the copy set up, with the proper permissions, you can source
it.
Beware:
Note: Environment properties with spaces or special characters are interpreted by the Bash shell and can result in a different value.
- No module named settings_vars error in django debug toolbar
- Django Admin – add collapse to a fieldset, but have it start expanded
- Django time difference with F object
0👍
If you are trying to access the environment variables in eb script elastic beanstalk
Use this
$(/opt/elasticbeanstalk/bin/get-config environment -k ENVURL)
{ "Ref" : "AWSEBEnvironmentName" }
$(/opt/elasticbeanstalk/bin/get-config environment -k ENVURL)
- RuntimeError: Model class xxx doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
- How should I represent a bit flags int field in django admin?
- Exclude URLs from Django REST Swagger
- Django queryset __contains case sensitive?
- Fabric – sudo -u