To create a Virtual Private Cloud (VPC) using AWS CLI, follow these steps:
Open your terminal and configure AWS CLI with your credentials:
aws configure
Create a VPC with a CIDR block:
aws ec2 create-vpc --cidr-block 10.0.0.0/16
After creating the VPC, you can add components like subnets, route tables, and internet gateways.
Create a Subnet:
aws ec2 create-subnet --vpc-id <vpc-id> --cidr-block 10.0.1.0/24
Create an Internet Gateway:
aws ec2 create-internet-gateway
Attach the internet gateway to your VPC:
aws ec2 attach-internet-gateway --vpc-id <vpc-id> --internet-gateway-id <igw-id>
Component | Description |
---|---|
VPC | Virtual Private Cloud, defines the network space. |
Subnet | Divides the VPC into smaller networks. |
Internet Gateway | Enables internet access for public subnets. |