Course contentsShow
← Cloud and Infrastructure
Lesson 406 of 2,9898. Managed DatabasesFree lesson

Security Groups for Database Access

Setting up security groups to control inbound and outbound network access to database instances.

Security Groups for Database Access

What you'll learn: How to use security groups as virtual firewalls to precisely control which applications and users can connect to your managed databases.


The Virtual Bouncer at Your Database Door

A security group acts like a bouncer at a nightclub entrance for your database. It checks every incoming and outgoing network connection against a list of rules you define. If a connection attempt matches an approved rule, it's allowed through. If not, it's blocked—no questions asked.

Without security groups, your database would be exposed to the entire network (or worse, the internet). Security groups let you say: "Only my web server on port 3306 can talk to this MySQL database" or "Only traffic from our internal network can reach this instance."

How Security Groups Work

Security groups operate at the instance level, meaning each database instance can have one or more security groups attached. Each security group contains:

  • Inbound rules: What traffic can reach your database (e.g., TCP port 5432 from a specific IP range)
  • Outbound rules: What traffic your database can send out (often left wide open for updates and backups)

Rules specify:

  • Protocol (TCP, UDP, etc.)
  • Port (3306 for MySQL, 5432 for PostgreSQL, 1433 for SQL Server)
  • Source/destination (IP ranges, other security groups, or specific instances)

Practical Example

If you created an RDS PostgreSQL instance in subnet group private-db, you'd attach a security group allowing inbound TCP on port 5432 only from your application server's security group. Your database remains invisible to everything else.

Key Takeaway: Security groups are stateful firewalls that control database network access through allow-list rules, forming your first line of defense against unauthorized connections.