AWS Builder Center
Your AWS Database Is Public. Would You Leave It That Way?

Your AWS Database Is Public. Would You Leave It That Way?

Your AWS database is working, but is it secure? Explore a real-world AWS architecture scenario involving EC2, Amazon RDS, VPC, public and private subnets, and security groups. Learn why database exposure matters and decide which architecture you'd choose.

Your AWS Database Is Public. Would You Leave It That Way?

Imagine you have just deployed your first web application on AWS.
Your website is working. Users can access it. Your application connects to a database, and everything seems fine.
But there is one important question:
What if your database is directly accessible from the internet?
Would you leave it that way because the application is working, or would you redesign the architecture?
Let's look at this scenario.

1. The Common Beginner Approach

A beginner might deploy an EC2 instance and a database with public accessibility enabled.
It may seem convenient because everything is easy to access and configure.
However, convenience should not be the main consideration when designing cloud infrastructure.
A publicly accessible database increases the potential attack surface, particularly if its security rules are not configured correctly.

2. A Better Architecture

A more secure design separates the application components into different network layers.
A typical architecture could look like this:
Internet → Application Load Balancer → Application Servers → Database
Here is how the components work:
  • Public subnet: Hosts the Application Load Balancer, which receives incoming application traffic.
  • Private subnet: Hosts application servers that should not receive direct public internet connections.
  • Private database subnet: Hosts the database, which should accept connections only from authorized application components.
Amazon VPC allows you to configure separate subnets and routing rules to support this design.
Security groups can further restrict which resources are allowed to communicate with one another.

3. Why Does This Matter?

Keeping a database private helps reduce unnecessary internet exposure.
For example:
  • Users access the application through its public endpoint.
  • The application communicates with the database.
  • The database accepts connections only from the application's security group.
  • Database access is not directly exposed to the public internet.
This is an example of applying network isolation and least-privilege access.

4. Is a Public Database Always Wrong?

Not every architecture has identical requirements.
There can be legitimate situations where a database requires public connectivity, such as specific external integration scenarios.
However, public accessibility should be an intentional decision with appropriate authentication, network restrictions, encryption, and monitoring—not simply the default configuration.

5. Think Like a Cloud Architect

Before deploying an application, ask yourself:
  • Does this resource really need public access?
  • Which component should be allowed to communicate with it?
  • Can I restrict access using security groups?
  • Are my network routes configured correctly?
  • Am I exposing anything unnecessarily?
Good cloud architecture is not just about making an application work. It is about making it secure, reliable, and maintainable.

Let's Discuss

Imagine you are designing an AWS application with an EC2-based application server and an Amazon RDS database.
Which architecture would you choose?
A. Both EC2 and RDS are publicly accessible.
B. EC2 is public, and RDS is private.
C. Both are private, accessed through a controlled entry point.
D. It depends on the application requirements.
I'd particularly like to hear from experienced AWS builders: what would you choose, and what security considerations would influence your decision?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article