AWS CLI with VPC

AWS CLI with VPC


Create VPC

To create a Virtual Private Cloud (VPC) using AWS CLI, follow these steps:

This section covers basic VPC creation using AWS CLI.
  1. Open your terminal and configure AWS CLI with your credentials:

    aws configure
    
  2. Create a VPC with a CIDR block:

    aws ec2 create-vpc --cidr-block 10.0.0.0/16
    
Ensure you use a unique CIDR block that doesn’t overlap with other networks.

Create VPC Components

After creating the VPC, you can add components like subnets, route tables, and internet gateways.

  1. Create a Subnet:

    aws ec2 create-subnet --vpc-id <vpc-id> --cidr-block 10.0.1.0/24
    
  2. 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>
    
Ensure you modify the route table to allow internet traffic for public subnets.

Tables

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.