AWS CLI with VPC

AWS CLI with VPC

  1. Create a VPC using CLI
aws ec2 create-vpc --cidr-block 10.0.0.0/16 --query Vpc.VpcId --output text

AWS CLI

  1. Create a subnet based on VPC ID
aws ec2 create-subnet --vpc-id **VPC-ID** --cidr-block 10.0.1.0/24

AWS CLI

  1. Create a second subnet
aws ec2 create-subnet --vpc-id **VPC-ID** --cidr-block 10.0.2.0/24

AWS CLI

Notes:

  • Ensure the correct VPC ID is provided when creating subnets.

Use aws ec2 describe-vpcs to list all VPCs and find the correct VPC ID.