Elastic Beanstalk定制AMI无法看到环境变量 [英] Elastic Beanstalk custom AMI can't see environment variables

查看:71
本文介绍了Elastic Beanstalk定制AMI无法看到环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些大包装要求,我将自定义AMI用于Elastic Beanstalk。

I'm using a custom AMI for Elastic Beanstalk because of some large package requirements.

当我通过SSH进入EC2实例时,我的应用程序都无法使用我的环境变量(在Elastic Beanstalk Web控制台设置中指定)。

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.

在使用SSH控制台时,如何使所有环境变量可用?

How do I make all of the environment variables available when I'm using the SSH console?

推荐答案

找到了一种简单的方法在阅读Elastic Beanstalk支持论坛时加载所有环境变量:

Found an easy way to load all the environment variables while perusing the Elastic Beanstalk support forums:

. /opt/python/current/env

要查看变量: echo $ {VAR_NAME} printenv VAR_NAME ,在使用上述命令之前不起作用。 ( UNIX,获取环境变量

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

奖金:

仅查看变量列表: printenv

要列出导出变量: cat / opt / python / current / env

要将导出添加到配置文件的末尾: cat / opt / python / current / env>> / path / to / my / file

To add the exports to the end of a config file: cat /opt/python/current/env >> /path/to/my/file

这篇关于Elastic Beanstalk定制AMI无法看到环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆