3

所以我有一个在弹性beantalk上运行的python应用程序。

我正在使用 ebextensions 来处理大量环境配置以及诸如数据库之类的资源配置。

在 ebextensions 我有:

+-- .ebextensions
  +-- db.config (The database resource file)
  +-- packages.config (Tells the instances to install postgres via yum)
  +-- python.config (Tells the instances what the WSGI path is.)

db.config 看起来像:

Resources:
AWSEBRDSDatabase:
    Type: AWS::RDS::DBInstance
    Properties:
        AllocatedStorage: 5
        DBInstanceClass: db.t2.micro
        DBName: development
        Engine: postgres
        EngineVersion: 9.5
        MasterUsername: testuser
        MasterUserPassword: pa$$word

包.config:

packages:
  yum:
    postgresql95-devel: []

蟒蛇配置:

option_settings:
- namespace: aws:elasticbeanstalk:container:python
  option_name: WSGIPath
  value: application/application.py

我遇到的问题是这个。

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-rds.html中,

它指出,当通过 Elastic Beanstalk 配置 RDS 实例时,将在实例中设置数据库的环境变量。

RDS_HOST
RDS_DB_NAME
RDS_USERNAME
RDS_PASSWORD
RDS_PORT

但是我的python代码调用:

os.environ["RDS_HOST"]

什么都得不到。曾经。对于任何变量。

我已经通过两种方式做到了这一点。第一个是在创建后添加到配置中。我尝试从头开始制作一个全新的环境。

两次都没有创建环境变量。

我知道我可以通过 AWS gui 手动执行此操作,但我想避免这种情况,因为我们的生产实例必须以自动化方式创建而无需 gui 交互。

4

0 回答 0