Elastic Beanstalk 自定义 AMI 看不到环境变量 [英] Elastic Beanstalk custom AMI can't see environment variables
问题描述
由于一些大包要求,我正在为 Elastic Beanstalk 使用自定义 AMI.
当我通过 SSH 连接到 EC2 实例时,我的应用程序没有任何环境变量(在 Elastic Beanstalk Web 控制台设置中指定)可用.
我的生产应用程序可以很好地访问变量,但我不能在控制台中这样做,这确实使调试任何事情变得非常困难.
如何在使用 SSH 控制台时使所有环境变量都可用?
在仔细阅读 Elastic Beanstalk 支持论坛时找到了一种加载所有环境变量的简单方法:
<预><代码>./选择/蟒蛇/当前/环境查看变量:echo ${VAR_NAME}
或 printenv VAR_NAME
,在使用上述命令之前不起作用.(UNIX,获取环境变量)
奖励:
要简单地查看变量列表:printenv
将变量列为导出:cat/opt/python/current/env
将导出添加到配置文件的末尾:cat/opt/python/current/env >>/path/to/my/file
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?
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
这篇关于Elastic Beanstalk 自定义 AMI 看不到环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!