Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to connect Django in EC2 to a Postgres database in RDS?

First time using AWS services with Django.

Was wondering how to configure the Django app running in a EC2 instance to a Postgres database in RDS?

the EC2 is running ubuntu 14.04

Any special configuration required?

like image 830
Kim Stacks Avatar asked Apr 29 '15 00:04

Kim Stacks


1 Answers

All you need to do, before doing the normal migration documented in the official tutorial be sure to have your RDS instance available and accessible to your EC2 instance.

Then what you need to do, is to modify the settings.py file of your app in the DATABSES section in the following way

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': '<name defined upon RDS creation>',
    'USER': '<username defined upon RDS creation>',
    'PASSWORD': '<password defined upon RDS creation>',
    'HOST': '<this can be found in "Endpoint" on your RDS dashboard, exclude the ":" and the port number>',
    'PORT': '5432',
    }
}

Following this, continue to migrate normally and all should work well.

like image 189
bluesummers Avatar answered Sep 28 '22 03:09

bluesummers