AWS Networking with CLI
Aws CLI
# install aws cli
choco install awscli
aws configure:
aws ec2 create-vpc --cidr-block 10.0.0.0/16 --tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=MyVpc}]'
aws ec2 create-subnet --vpc-id vpc-021088027e5a7b9c9 --cidr-block 10.0.1.0/24 --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=pub-1}]'
aws ec2 create-subnet --vpc-id vpc-021088027e5a7b9c9 --cidr-block 10.0.2.0/24 --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=pub-2}]'
aws ec2 create-subnet --vpc-id vpc-021088027e5a7b9c9 --cidr-block 10.0.3.0/24 --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=pv-1}]'
aws ec2 create-subnet --vpc-id vpc-021088027e5a7b9c9 --cidr-block 10.0.4.0/24 --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=pv-2}]'
aws ec2 describe-subnets --filters "Name=vpc-id,Values=vpc-021088027e5a7b9c9"
aws ec2 create-route-table --vpc-id vpc-021088027e5a7b9c9 --tag-specifications 'ResourceType=route-table,Tags=[{Key=Name,Value=public-route}]'
aws ec2 create-route-table --vpc-id vpc-021088027e5a7b9c9 --tag-specifications 'ResourceType=route-table,Tags=[{Key=Name,Value=pv-route}]'
# Activity
1. create IGW & Nat gateway
2. create route in public route table attach IGW and add public subnets assocation
3. create route in pv route table attach NAT gateway and add pv subnets assocation