Creating a VPC with Subnet, Security Group, and EC2 instance using Terraform on AWS(Part04)

CodeWithMuh
9 min readApr 20, 2023
https://youtube.com/@codewithmuh

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:

  1. Create VPC
  2. Create Internet Gateway
  3. Create Custom Route Table
  4. Create Subnet
  5. Associate Subnet with Route Table
  6. Create Security Group to allow ports: 22, 80, 443

--

--

CodeWithMuh
CodeWithMuh

Written by CodeWithMuh

Entrepreneur | Software Developer | AWS DevOps | Python, Django, Backend Developer | Tech Writer - Empowering Startups to Build Exceptional Web and Mobile Apps

No responses yet