How to Create VPC & Subnets on Amazon Web Service(AWS).
Amazon Virtual Private Cloud (Amazon VPC) is a service that lets you launch AWS resources in a logically isolated virtual network that you define. You can use both IPv4 and IPv6 for most resources in your virtual private cloud, helping to ensure secure and easy access to resources and applications.
A public subnet is a subnet that’s associated with a route table that has a route to an internet gateway. A private subnet with a size /24 IPv4 CIDR block. This connects the VPC to the internet and to other AWS services. Instances with private IPv4 addresses in the subnet range.
- Login to aws portal.
- Click on Services.
- Under Networking & Content Delivery select VPC.
VPC(virtual private cloud)
- Click on VPCs.
- Click on Create VPC.
- Provide VPC tag name.
- Provide IPv4 CIDR block.
- Select Tenancy :Dedicated or default. Dedicated tenancy ensures all EC2 instances that are launched in a VPC run on hardware that’s dedicated to a single customer instead, they can use the AWS CLI/SDK to ensure that all new instances in the VPC are launched with default tenancy.
- Click on Create VPC.
- After sometime VPC is ready.
Subnets
- Then click on Subnets.
- Click on Create subnet.
- Select existing VPC ID.
- Then add a subnet.
- Provide subnet tag name.
- Select availability zone.
- Provide IPv4 CIDR block.
- We can add multiple subnets as per requirements.
- Click on Create subnet.
- After sometime Subnet is ready.
Create VPC & Subnet using Shell
- Setup aws-cli on your system so click on link https://www.hackerxone.com/blog/how-install-configure-aws-cli-ubuntu-1804
- Run the following command:
To create a VPC
aws ec2 create-vpc –cidr-block 10.0.0.0/16
To create a VPC with dedicated tenancy
aws ec2 create-vpc –cidr-block 10.0.0.0/16 –instance-tenancy dedicated
To create a Subnet
aws ec2 create-subnet –vpc-id existing-vpc-id –cidr-block 10.0.1.0/24