Creating a VPC with Subnet, Security Group, and EC2 instance using Terraform on AWS(Part04)
In Previous Part 01, Part 02, and Part 03- We have discussed Introduction to Terraform, Terraform, and aws cli Setup.In this Part 04 article, we will be discussing the fourth part of the Terraform series, where we will be creating a VPC with a Subnet, Security Group, and EC2 instance. We will create an Amazon Virtual Private Cloud (VPC) with a Subnet, Internet Gateway, and Custom Route Table using Terraform. We will then create an Elastic Network Interface (ENI) and associate an Elastic IP (EIP) address with it. We will also create a Security Group to allow ports 22, 80, and 443. Finally, we will create an EC2 instance and install Apache2 on it.
By the end of this article, you will have a solid understanding of creating a VPC with Subnet, Security Group, and EC2 instance using Terraform. Let’s begin by discussing the project outline.
Project Outline
The project outline consists of the following steps:
- Create VPC
- Create Internet Gateway
- Create Custom Route Table
- Create Subnet
- Associate Subnet with Route Table
- Create Security Group to allow ports: 22, 80, 443