Overview
- A VPC defines the overall IP address space for your network in AWS.
- Subnets carve out CIDR blocks inside that VPC and are tied to specific Availability Zones.
- When you launch an EC2 instance into a subnet, the instance receives a private IP from the subnet’s CIDR and is placed in that subnet’s AZ.
Step 1 — Create the VPC
In the VPC console choose Create VPC (VPC only). For this demo use:- Name: Demo VPC
- IPv4 CIDR block:
10.0.0.0/16 - (Optional) Amazon-provided IPv6 CIDR block
Step 2 — Create subnets in the VPC
Go to Subnets → Create subnet. Select the Demo VPC, provide a name (e.g., Subnet 1) and pick an Availability Zone. In the N. Virginia region you may see AZ identifiers such asus-east-1a, us-east-1d, etc. If you choose “No preference,” AWS will assign an AZ for you.
Important constraints:
- A subnet’s CIDR must be a block contained within the parent VPC CIDR. For example,
192.168.1.0/24is invalid in a10.0.0.0/16VPC. A valid example is10.0.1.0/24. - Optionally assign an IPv6 CIDR when creating the subnet if your VPC has an IPv6 pool.
A subnet’s IPv4 CIDR must be a block within the parent VPC’s CIDR range. Always plan your VPC and subnet ranges to avoid overlaps.
Create Subnet 1 with CIDR
10.0.1.0/24 in us-east-1d, then create Subnet 2 with CIDR 10.0.5.0/24 in us-east-1a. You can filter the Subnets list by VPC to show only subnets that belong to Demo VPC.

Step 3 — Launch an EC2 instance into a subnet
When you launch an EC2 instance, selecting a subnet determines:- The Availability Zone the instance will be placed in.
- The private IP address range from which the instance’s private IPv4 will be allocated.
- Go to EC2 → Launch Instance.
- Choose an AMI and instance type (e.g., Amazon Linux 2023,
t2.micro). - Select or create a key pair.
- Under Networking, select Demo VPC and pick the subnet (for example, choose Subnet 2 to place the instance in
us-east-1a). - Configure public IP assignment and other options as needed, then click Launch.

10.0.5.113, which is inside 10.0.5.0/24 (Subnet 2) and the instance is placed in us-east-1a.

Cleanup — terminate instances and delete the VPC
When finished with the demo, terminate the instance and then delete the VPC. Deleting a VPC removes its subnets and other dependent resources automatically, but only if there are no remaining dependent resources attached.You must terminate or detach any dependent resources (instances, ENIs, NAT gateways, etc.) before deleting a VPC. The console will block deletion until those resources are removed.
- Confirm all instances, network interfaces, NAT gateways, and other resources are terminated or detached from the VPC.
- In the VPC console, select the VPC → Actions → Delete VPC.
- The console will display resources that will be removed and request confirmation. Type
deleteto confirm before the VPC is deleted.

Summary
- Plan your VPC CIDR and subnet CIDRs to avoid overlap.
- Each subnet is tied to a single Availability Zone; launching into that subnet places the instance in the corresponding AZ.
- The instance’s private IPv4 is allocated from the subnet’s CIDR block.
- Always clean up dependent resources before deleting a VPC.