Terraform & Devops
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us
No Result
View All Result
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us
No Result
View All Result
Terraform & Devops
No Result
View All Result
Home TERRAFORM CERTIFCATION

Implementing VPC Architecture using Terraform

by abubakarsiddiq858
August 28, 2021
in TERRAFORM CERTIFCATION
129 7
0
Implementing VPC Architecture using Terraform
156
SHARES
1.9k
VIEWS
Share on FacebookShare on Twitter

Figure :Architecture for vpc with Terraform

Definition of VPC:

The Crispy Definition of VPC is Its a Isolated network.vpc has Several Components like NatGateway, InternetGateway, Routers, Elastic IP and Route tables ,Security Group and NACL.Lets see how to Create a vpc and configure its components.

IP addresses reserved by vpc there are 5 IP addresses reserved by vpc

10.0.0.0: Network address.

10.0.0.1: Reserved by AWS for the VPC router.

10.0.0.2: Reserved by AWS DNS Server

10.0.0.3: Reserved by AWS for future use.

10.0.0.255 Network broadcast address. AWS do not support broadcast in a VPC, therefore its reserve this address.

Source code for VPC

Figure vpc

Subnets in VPC:

when we create a VPC its a Large network.we need to Divide it into small portion of Networks called Subnets.

“one subnet can be associated with only one route table”.

One goal of a subnet is to split a large network into a grouping of smaller, interconnected networks to help minimize traffic.

we are dividing the above VPC Cidr ranges to /25 network

Public subnet

A public subnet is a subnet that’s associated with a route table that has a route to an internet gateway.

Public subnets are good usecases for webservers.

The complete source code can be found in the below repository

https://github.com/Jaffarterraform786/vpc

Source code for public subnet

Figure Public Subnet

Private subnets

If a subnet doesn’t have a route to the internet gateway, the subnet is known as a private subnet.

private subnets are good use cases for Database servers.

Source code for Private subnets

Figure Private subnet

Internet Gateway:

An Internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between instances in your VPC and the Internet. Internet gateway allows both inbound and outbound traffic

Route Table

A route table specifies how packets are forwarded between the subnets within your VPC, the internet, and your VPN connection.

To create a route table

here we are creating a public route table with the name “publicroutetable” in the same way create a private Route table with the name “private routetable”.

Figure Public Route Table

Figure Private Route Table

Elastic IP

An Elastic IP address is a static, public IPv4 address.An account can have Max 5 Elastic IPS.

Figure Elastic IP

Natgateway:

Natgateway defines You can use a network address translation (NAT) gateway to enable instances in a private subnet to connect to the internet or other AWS services, but prevent the internet from initiating a connection with those instances.It clearly states that nat gateway allows only outbound connections it means we must be part of the network to acess the internet.

Nat Gateway are good usecases for a data base server. for example we can do patching upadates for a DBserver as we are part of the network we can connect and update the database server.External users cannot directly hit my servers.

The instances in the private subnet can access the Internet by using a network address translation (NAT) gateway that resides in the public subnet. … A NAT gateway must be created in a VPC with an Internet Gateway. Otherwise, the NAT gateway won’t work

Source code for Nat gateway:

Figure Nat gateway

Editing Routes for public subnet:

Now we need to instruct the publicroute table how the traffic should fallow.in case of public subnet we need to instruct the route that is if the destination is internet 0.0.0.0/0 then target will be internet gateway.It means that anytime if we need to reach the internet both inbound and outbound traffic flows through internet gateway.

public subnet edited Table

Editing Route table for Private subnet:

Now we need to instruct the public route table how the traffic should fallow.in case of public subnet we need to instruct the route that is if the destination is internet 0.0.0.0/0 then target will be natgateway. in this case external users cannot hit the servers Directly.

Source code:

Private subnet route table

Let's Do terraform plan and see how the resources are created.

we can clearly see 12 resources will be added .this is how we provision a vpc with nat and internet gateway.
  • Trending
  • Comments
  • Latest
Terraform – Modules

Terraform – Modules

January 4, 2021
Terraform Life cycle

Terraform Life cycle

January 4, 2021
Terraform – Functions

Terraform – Functions

January 4, 2021
Terraform installation

Terraform installation

January 4, 2021
Implementing VPC Architecture using Terraform

Implementing VPC Architecture using Terraform

0
Local and dynamic blocks:

Local and dynamic blocks:

0
Terraform  Provisioners

Terraform Provisioners

0
Managing Terraform States in Remote Locations:

Managing Terraform States in Remote Locations:

0
Implementing VPC Architecture using Terraform

Implementing VPC Architecture using Terraform

August 28, 2021
Build a CICD Pipeline with Git Jenkins Terraform

Build a CICD Pipeline with Git Jenkins Terraform

May 24, 2021

Configuring VPC Components in AWS

February 8, 2021

Introduction to AWS

February 7, 2021

Recent News

Implementing VPC Architecture using Terraform

Implementing VPC Architecture using Terraform

August 28, 2021
Build a CICD Pipeline with Git Jenkins Terraform

Build a CICD Pipeline with Git Jenkins Terraform

May 24, 2021

Categories

  • Uncategorized
  • AWS-CLOUD
  • TERRAFORM CERTIFCATION

Site Navigation

  • Home
  • Advertisement
  • Contact Us
  • Privacy & Policy
  • Other Links
Terraform & Devops

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Check our landing page for details.

No Result
View All Result
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us

© 2021 TheTerraform.in - All Rights Reserved.
Designed By TenXinfotech.

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist