Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

How to Install Terraform

Table of Contents

  • Terraform is an open-source Infrastructure-as-Code (IaC) tool developed by HashiCorp.
  •  It lets you provision and manage cloud infrastructure using declarative configuration files.

How to Install Terraform

Install Terraform CLI

wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list

sudo apt update && sudo apt install terraform

Project Structure

terraform-aws-ec2/

├── main.tf

├── variables.tf

main.tf

provider "aws" {
  region = var.region
}

resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0" # Change based on your region
  instance_type = "t2.micro"

  tags = {
    Name = "Terraform-Example"
  }
}

variables.tf 

variable "region" {
  default = "us-east-1"
}

Here, the provider tells Terraform that you’re working with AWS as your cloud provider.

resource defines a resource block that tells Terraform to create an EC2 instance.

variable.tf file  is used to define input variables, making your config reusable and configurable.

Running Terraform

Initialize the project

terraform init

Initializes plugins/providers and backend.

Plan the changes

terraform plan

Shows what Terraform intends to do.

Apply the changes

terraform apply

Creates the EC2 instance.

You’ll be asked to confirm with yes.

Terraform empowers you to automate, version, and manage your infrastructure consistently across different environments and cloud providers. Whether you’re working with AWS, Azure, GCP, or even Kubernetes, Terraform gives you the tools to treat your infrastructure like code—reliable, repeatable, and under version control.

Need assistance to install Terraform or optimize your cloud management strategy? Our experts are ready to guide you. Reach out now for professional support.

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Let us know your requirement.

Can't get what you are looking for?

Get Support Right Away!