Getting Started with Terraform: Deploying Your First AWS Infrastructure Using Terraform Configuration Files (Part 3)

CodeWithMuh
3 min readApr 20, 2023
https//www.youtube.com/@codewithmuh

Introduction

In the previous parts(Part 01, Part 02) of this Terraform series, we discussed Terraform and its key features and concepts, and we also walked through the installation and configuration of the AWS CLI and Terraform. In this part, we will create our first Terraform configuration file and deploy it to AWS.

Terraform uses configuration files to define the desired state of your infrastructure. These configuration files are written in the HashiCorp Configuration Language (HCL) or JSON. In this article, we will use HCL to write our configuration files.

Creating Your First Terraform Configuration File

To create your first Terraform configuration file, follow these steps:

  1. Open a text editor of your choice.
  2. Create a new file and name it main.tf.
  3. Copy and paste the following code into main.tf:
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
}

--

--