DEV Community

Rahul Wagh
Rahul Wagh

Posted on

AWS VPC Explained with Terraform

Amazon Web Services (AWS) lets you build and run Virtual Private Clouds (VPCs) with different parts. VPCs are virtual networks that are separate from each other in the AWS cloud. They let you start resources like EC2 servers, RDS databases, and more.

In this lab session, we are gonna take a look on setting up following using Terraform -

  1. How to setup VPC?
  2. How to setup Subnet?
  3. How to setup Internet Gateway?
  4. How to setup NAT gateway?
  5. How to setup Route Table
  6. How to setup Elastic IP?


VPC, or Virtual Private Cloud, is a virtual network that is specific to your AWS account and keeps your resources separate and under your control. It is conceptually different from other VPCs, so you can set up your own IP address ranges, subnets, and routing tables.


Subnet is a part of the IP address range for your VPC. Subnets can cross multiple Availability Zones (AZs), so you can spread out your resources to make sure they are always available and can handle problems.

Internet Gateway

Internet Gateway: A gateway that connects your VPC to the internet and can be scaled horizontally and used more than once.

NAT Gateway

NAT Gateway is a controlled network address translation (NAT) service that lets instances in a private area connect to the internet or other AWS services, but stops the internet from connecting to those instances.

Route Table:

Route Table A set of rules, called routes, that tells your VPC where to send network data.

*Elastic IP: *

Elastic IP: A public IPv4 address that is always the same and that you can link to an instance, a network device, or a NAT gateway. Elastic IPs help you keep track of your resources that are available to the public and let you remap numbers to other resources in case something goes wrong.

After making and setting these parts, your VPC will have public and private subnets, an Internet gateway for public access, a NAT gateway for private access, custom route tables, and Elastic IPs for static public addresses.

▬▬▬▬▬▬ ⭐️ Follow me ⭐️ ▬▬▬▬▬▬

Linkedin -
Twitter -

To learn more on DevOps visit -

Top comments (0)