VPC and Subnet

VPC

SAIRAM MANDAPAKA
4 min readJan 4, 2021

VPC stands for virtual private cloud, Simply a VPC is a private subsection of AWS that you control in which you can place AWS resources such as EC2 instances and databases, you will have full control over the AWS resources that you place inside your VPC.

Amazon Virtual private cloud lets you provision a logically isolated section of the Amazon web services cloud where you can launch AWS services in a virtual network you define, You will have complete control over your virtual networking environment, including the section of your own IP address range, creating subnets and configuration of route tables and network gateways.

The most essential benefits you can get from a virtual private cloud are privacy, security, and prevention of loss of proprietary data.

Configuring a VPC

  1. Go to the AWS console.
  2. Go to the Networking and content delivery section and click VPC.
  3. We can also find VPC by typing VPC in the search bar.
  4. Make sure you have selected an appropriate region.
  5. Now you will be taken to the VPC console.
  6. Click on your VPC option on the left side pane.
  7. You will go to the VPC dashboard and you can see a default VPC already created for the instance you created.
  8. Click on the create VPC button on the upper pane.
  9. You will be asked to assign a name and an IP address based on the CIDR block, Make sure you give the appropriate IP like 10.0.0.0/16.
  10. Fill in all the parameters you need and click on create VPC.
  11. Now the VPC will be created and you can see the created VPC in your VPC dashboard.

Configuring a Subnet

  1. Go to the Networking and content delivery section and click VPC.
  2. Now you will be taken to the VPC console.
  3. Click on the subnet option below your VPC option on the left side pane.
  4. You will go to the subnet dashboard and you can see a default Subnet already created for the instance you created.
  5. Click on the create Subnet button on the upper pane.
  6. You will be redirected to fill in the details like the name of the subnet, VPC, Availability zone, etc.
  7. Make sure you select the VPC you created for the Subnet.
  8. Also, make sure that your subnet and VPC resides in the same region.
  9. While selecting Region make sure you choose the availability zone you want.
  10. While giving the CIDR IP address make sure that the address resides in the VPC addressing range like 10.0.1.0/24.
  11. Click on the create button.
  12. Now in the subnet dashboard you will see your subnet created.
  13. Make sure you create two subnets one for private and another one for the public.

Creating Route Tables

  1. Go to the Networking and content delivery section and click VPC.
  2. Now you will be taken to the VPC console.
  3. Click on the Routing table option below your subnet option on the left side pane.
  4. Click on create a Routing table
  5. On the route table tab, you will be asked to specify a name and a VPC.
  6. Click create. And click on the Route option-click edit routes and click add route and add a route and save it. Make sure you select the internet gateway you created as a target.
  7. Now we will select the subnet and click on the subnet association we have created and click on the edit subnet association tab and click on assign
  8. Click on the public subnet and click save, Now we will select the subnet and click on the subnet association we have created and click on the edit subnet association tab and click on assign
  9. Click on the private subnet and click save.
  10. Now select Internet Gateways and click on create an Internet Gateway.
  11. Give a name and click create and you will see that when a gateway s created you will see the gateway status as detached.
  12. Select the Internet Gateway and right-click on it and click on Attach to VPC.
  13. You will be prompted to select a VPC and select the VPC you have created.
  14. Click on attach.
  15. Now go to the security group option and click on it.
  16. You will see a default security group is already created for you to select the security group.
  17. Click on Inbound rules an click on edit rules and click add a rule.
  18. For type select all traffic and for protocol select all and for port range select all.
  19. For source select My IP and copy the IP and click on save.
  20. Now come to the VPC dashboard and click Network ACLs.
  21. A default NACL is created select that and click on Inbound Rules.
  22. In the inbound rules in the source section IP with the IP address, you copied and click save.

Now while creating an Instance select the appropriate VPC and the Subnet and the security Groups while configuring the EC2 instance.

Introduction to AWS CLI

AWS CLI is an Amazon web services Command-line interface where we can work/manage/operate AWS services from the command line.

With AWS CLI we can control services manually or automate them with powerful scripts like shell and python.

AWS CLI commands are like Linux commands which are used to work with any of our AWS services from the command line of our localhost.

some of the popular AWS CLI commands are :

  1. aws s3 ls: List all buckets.
  2. aws ec2 describe-instances: List all EC2 instances.

--

--