So, we need to connect our docker based django app to our RDS instance, here are the steps to do so.
Step 1
Remove DATABASE_URL=postgres://postgres
from .envs/.production/.django
Step 2
Update .envs/.production/.postgres
and setup your database credentials.
POSTGRES_HOST= # db host
POSTGRES_PORT= # db port
POSTGRES_DB= # db name
POSTGRES_USER= # db user
POSTGRES_PASSWORD= # db pass
Step 3
Comment or remove Postgres volumes and services from production.yml
file.
You will have to remove the complete postgres
service.
# Filename: /production.yml`
volumes:
# production_postgres_data: {} ## Remove or comment this
# production_postgres_data_backups: {} ## Remove or comment this
...
services:
django: &django
depends_on:
# - postgres ## Remove or comment this
# postgres: ## Remove or comment this whole block
...
Your Django app should now connect to your RDS database in production.
Feel free to leave any feedback or queries.