Reputation: 358
Weird problem deploying Django on EB with Postgres.
Context: deploying a Django app on Elastic Beanstalk with postgresql 9.5. I've tried on two separate Windows 10 machines with the same results. Python 3.5 and Django 1.10.4.
Problem: when connecting to the database using the RDS environment variable, I accidentally look for "RDS_USER" rather than "RDS_USERNAME" in settings.py. This, naturally, throws a KeyError for "RDS_USER".
However, if I change this to the proper value, commit the changes and re-deploy, eb does not pick up the changes.
I still get the same KeyError for "RDS_USER" when trying to run a migration.
I can replicate this after modifying settings.py for postgres and adding some commands (venv, migrations)/packages (git, postgresql95-devel).
Has anyone else experienced this?
If I create a new instance and deploy initially with the proper variable name, it works fine.
settings.py:
if 'RDS_DB_NAME' in os.environ:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ['RDS_DB_NAME'],
'USER': os.environ['RDS_USERNAME'],
'PASSWORD' : os.environ['RDS_PASSWORD'],
'HOST': os.environ['RDS_HOSTNAME'],
'PORT':os.environ['RDS_PORT']
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'name',
'USER':'user',
'PASSWORD':'password',
'HOST':'localhost',
'PORT':''
}
}
Upvotes: 0
Views: 246
Reputation: 1507
I use awscli as well and my DB settings look just like yours and they work fine. Did you try to create a new EB instance and see if that works?
Upvotes: 1