ebextensions RDS Provisioning does not set Environment Variables

384 views Asked by At

So i have a python application running on elastic beanstalk.

I am using ebextensions to handle a lot of the environment configuration as well as resource provisioning such as a database.

In ebextensions i have:

+-- .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 looks like:

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

packages.config:

packages:
  yum:
    postgresql95-devel: []

python.config:

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

The problem i am having is this.

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

it states that when an RDS instance is provisioned via Elastic Beanstalk that the environment variables for the database will be set within the instances.

RDS_HOST
RDS_DB_NAME
RDS_USERNAME
RDS_PASSWORD
RDS_PORT

But my python code which makes calls:

os.environ["RDS_HOST"]

Doesn't get anything. Ever. For any of the variables.

I've done this in two ways. The first by adding to the config after creation. And i tried making a brand new environment from scratch.

Both times the environment variables aren't being created.

I understand that i can do this through the AWS gui manually but i want to avoid that as our production instances must be created in an automated fashion without gui interaction.

0

There are 0 answers