Getting Started with Terraform: Deploying Your First AWS Infrastructure Using Terraform Configuration Files (Part 3)
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:
- Open a text editor of your choice.
- Create a new file and name it
main.tf
. - 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"
}