如何设置在亚马逊弹性魔豆环境变量(蟒蛇) [英] How to set an environment variable in Amazon Elastic Beanstalk (Python)

查看:121
本文介绍了如何设置在亚马逊弹性魔豆环境变量(蟒蛇)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在Django应用程序最近,试图让它与Amazon弹性青苗工作。

I have been working on a Django application lately, trying to get it to work with Amazon Elastic Beanstalk.

在我的 .ebextensions / python.config 文件,我已经设置了以下内容:

In my .ebextensions/python.config file, I have set the following:

option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name:  ProductionBucket
    value: s3-bucket-name
  - namespace: aws:elasticbeanstalk:application:environment
    option_name:  ProductionCache
    value:  memcached-server.site.com:11211

但是,每当我期待在服务器上,没有这样的环境变量设置(正因为如此,都不能访问时,我尝试 os.getenv('ProductionBucket')

我碰到这个这似乎试图记录所有的命名空间这个页面。我也试着使用 PARAM1 作为选项名称,但也有类似的结果。

I came across this this page which appears to attempt to document all the namespaces. I've also tried using PARAM1 as the option name, but have had similar results.

我怎样才能在Amazon弹性魔豆设置环境变量?

How can I set environment variables in Amazon Elastic Beanstalk?

修改
我也尝试添加之前,所有其他命令的命令,它只会导出一个环境变量:

EDIT:
I have also tried adding a command prior to all other commands which would just export an environment variable:

commands:
 01_env_vars:
  command: "source scripts/env_vars"

...这也是不成功的。

... This was also unsuccessful

推荐答案

我使用的是现代的(即非传统的)容器检查,并发现它在/ opt / elasticbeanstalk /部署/配置/ containerconfiguration作为一个JSON文件

I've checked using a modern (i.e., non legacy) container, and found it under /opt/elasticbeanstalk/deploy/configuration/containerconfiguration as a json file.

的行为似乎是依赖于平台的:我记得在PHP特别是它还会创建一些shell脚本的价值。

The Behaviour seems to be Platform-Dependent: I remember in PHP in particular, it also creates some shell scripts with the values.

不管这一点,看看到/ opt / elasticbeanstalk /钩/ configdeploy。

Regardless of that, look into /opt/elasticbeanstalk/hooks/configdeploy.

Java的情况下再次运行该Python脚本,它看起来非常方便你:

Java case again, it runs this python script, which looks quite handy for you:

https://gist.github.com/19c1e4b718f9a70a4ce1

这篇关于如何设置在亚马逊弹性魔豆环境变量(蟒蛇)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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