AWS CLI for Networking
- Create a vpc and attach internet gateway
# Create VPC
aws ec2 create-vpc --cidr-block "192.168.0.0/23" `
--tag-specifications "ResourceType=vpc,Tags=[{Key=Name,Value=activity1}]"
# vpc-055037a4a184bf027
# Create internet gateway
aws ec2 create-internet-gateway `
--tag-specifications "ResourceType=internet-gateway,Tags=[{Key=Name,Value=activity1}]"
# igw-0c2ff11b082892e37
# attach internet gateway
aws ec2 attach-internet-gateway `
--vpc-id "vpc-055037a4a184bf027" `
--internet-gateway-id "igw-0c2ff11b082892e37"
- Create two subnets: Refer Here for the changes done
- Create a public route table and associate with public subnet. Add a route to internet gateway
- Create a private route table and associate with private rt
Refer Here
- Create a security group that opens 80 and 22 port from anywhere for public usage and a securtiy group which opens all ports within vpc.
- Refer Here for the changes to add security groups
Exercise
- Create a Network ACL which opens all 22 and 80 port from anywhere, all connections within vpc and denies the rest. attach this to public subnet
- Create a Network ACL which opens all connections within vpc and attach this to private subnet