i set up this environment on AWS:
VPC:
- 1 Public subnet
- Route table with Internet Gateway
- 2 Private subnets
- Route table with NAT
I created a subnetgroup with the private subnets and attached it to my RDS Postgres instance.
I Have a bunch of Lambdas in the same vpc (private subnets) that are connecting to the DB with no problem at all. I've added on the RDS Security Group the inbound rule to allow access from the Lambda Security Group and all is working fine.
I did the same thing for my EC2 in the same vpc (private subnet) where i'm hosting a Django Application.
The EC2 and the RDS are in the same az
Added the inbound rule on the RDS Security Group and added the RDS Full access (just for testing purposes) Policy to the EC2 IAM Role.
When i launch my application the build spec can download packages and resolve the host so i know my nat is working but when it does : python manage.py migrate
(which connects to the RDS) it goes in timeout:
django.db.utils.OperationalError: connection to server at "db-postgres-dev-postgresinstance-xxxxxxxx.xxxxxxxx.eu-central-1.rds.amazonaws.com" (x.xx.xx.xxx), port 5432 failed: Connection timed out
Is the server running on that host and accepting TCP/IP connections?
My NACLS
are default so the problem won't be there.
How do i solve this?