0
0
AwsConceptBeginner · 4 min read

What is VPC in AWS: Simple Explanation and Example

A VPC (Virtual Private Cloud) in AWS is a private network you create in the cloud to control your resources securely. It lets you decide your own IP addresses, subnets, and network settings, like having your own private data center in the cloud.
⚙️

How It Works

Think of a VPC as your own private neighborhood inside the huge city of AWS. Just like you control who can enter your neighborhood and how the roads connect, a VPC lets you control the network where your cloud resources live.

Inside your VPC, you create smaller areas called subnets, like blocks in your neighborhood. You decide which blocks are public (open to the internet) and which are private (only accessible inside your VPC). This setup helps keep your data safe and organized.

With a VPC, you also control the traffic rules using security groups and network access control lists, similar to setting up gates and guards to protect your neighborhood.

💻

Example

This example shows how to create a simple VPC with one public subnet using AWS CLI commands.

bash
aws ec2 create-vpc --cidr-block 10.0.0.0/16
aws ec2 create-subnet --vpc-id vpc-123abc --cidr-block 10.0.1.0/24
aws ec2 modify-subnet-attribute --subnet-id subnet-456def --map-public-ip-on-launch
aws ec2 create-internet-gateway
aws ec2 attach-internet-gateway --vpc-id vpc-123abc --internet-gateway-id igw-789ghi
aws ec2 create-route-table --vpc-id vpc-123abc
aws ec2 create-route --route-table-id rtb-101jkl --destination-cidr-block 0.0.0.0/0 --gateway-id igw-789ghi
aws ec2 associate-route-table --subnet-id subnet-456def --route-table-id rtb-101jkl
Output
VPC created with CIDR 10.0.0.0/16 Subnet created with CIDR 10.0.1.0/24 Subnet attribute modified to assign public IPs Internet Gateway created and attached Route table created and route added Route table associated with subnet
🎯

When to Use

Use a VPC when you want full control over your cloud network. It is essential for:

  • Keeping your resources isolated and secure from others.
  • Setting up public and private areas for different parts of your application.
  • Connecting your cloud network to your office network safely.
  • Managing traffic rules to protect your data.

For example, a company hosting a website and a database can put the website in a public subnet and the database in a private subnet inside a VPC to keep the database safe from the internet.

Key Points

  • A VPC is your private network in AWS.
  • You control IP addresses, subnets, and traffic rules.
  • It helps secure and organize your cloud resources.
  • Supports both public and private subnets.
  • Allows safe connection to your own data centers.

Key Takeaways

A VPC lets you create a private network in AWS to control your cloud resources securely.
You can divide your VPC into public and private subnets to separate internet-facing and internal resources.
Security groups and network ACLs in a VPC help protect your resources by controlling traffic.
Use VPCs to connect your cloud environment safely with your own office network.
Creating a VPC is the first step to building a secure and organized cloud infrastructure.