Create custom VPC with private and public subnets
Create a custom VPC with public and private subnets and run EC2 instances on it. In this blog we will use AWS CLI version2 to create a custom VPC along with private and public subnets and finally we will run new EC2 instances on this VPC. To begin with, let's create a VPC with name as paulVPC2 and CIDR-Block range as 192.168.0.0/16 using below aws cli command aws ec2 create-vpc ^ --cidr-block 192.168.0.0/16 ^ --tag-specifications="ResourceType=vpc,Tags=[{Key=Name,Value=paulVPC2}]" The symbol '^' is used in windows for line continuation similar to '\' in linux. To get the vpc-id of the above VPC use below aws cli command aws ec2 describe-vpcs ^ --output json In this VPC we will create a subnet with name=paulSubnet1 in Mumbai 1a AZ aws ec2 create-subnet ^ --cidr-block 192.168.1.0/24 ^ --vpc-id vpc-0855a7ab2ac29fb28 ^ --availability-zone ap-south-1a ^ --tag-specifications="ResourceType=subnet,Tags=[{Key=Name,Value=paulSubnet1}]" Insid