

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: RDS: Relational Database Service
incomplete
2: Create a PostgreSQL Database
incomplete
3: Connect to Your Database
incomplete
4: Connect App to Database
incomplete
5: RDS Storage and IOPS
incomplete
6: RDS Backups
incomplete
7: Read Replicas
incomplete
8: Cleanup
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Now that you have a database, we need our application server to connect to it. After all, they're in different subnets (public vs. private) in the same VPC. AWS adds a local route for your VPC CIDR by default, so subnets in that VPC can route to one another.
The key is security groups. Remember, security groups are like stateful firewalls that control traffic to and from your resources.
"Stateful" here just means we allow the return trip by default. If the firewall lets you out to https://www.boot.dev/, when that server responds to you it will also be allowed through the firewall.
Here's how traffic will flow from your application server to your database:
5432 (PostgreSQL default port)patientping-public-a subnet can reach your patientping-private-a subnet automatically.5432Configure security groups so your application server can reach the RDS instance on port 5432.
Cost check: No new billable resources in this lesson. You're only changing security group rules; your existing RDS instance (~$13/mo. for db.t3.micro) and EC2 instance costs are unchanged.
psql -h patientping-db.XXXXX.us-east-1.rds.amazonaws.com -U postgres -d patientping
Run and submit the CLI tests.
For AWS CLI users, here's the syntax to configure security group rules:
# Add outbound rule to app server security group (assuming you want a specific rule)
aws ec2 authorize-security-group-egress --group-id APP-SG-ID --ip-permissions IpProtocol=tcp,FromPort=5432,ToPort=5432,UserIdGroupPairs=[{GroupId=RDS-SG-ID}]
# Add inbound rule to DB security group
aws ec2 authorize-security-group-ingress --group-id RDS-SG-ID --ip-permissions IpProtocol=tcp,FromPort=5432,ToPort=5432,UserIdGroupPairs=[{GroupId=APP-SG-ID}]