What is Terraform ?

Terraform is one of the IaC tools that effectively support managing infrastructure changes. Whether storage or computing, it doesn’t matter whether Terraform can manage changes for any resource. Curious to know more about Terraform? It’s time to know. This tutorial will serve as a magnifying lens to learn more about Terraform. On the go, the tutorial will give you hands-on experience in installing and making changes in infrastructure using Terraform. Let’s kick start!

These days, infrastructure is one of the ever-changing entities in any organization. Especially changing an IT infrastructure is never an easy job. This is why companies are always searching for a powerful tool to execute infrastructure changes smoothly.

This way, Terraform is an infrastructure as a code (IaC) tool. It provides on-premises and cloud resources into human-readable files to easily be used and shared with other applications.

Terraform is an open-source and infrastructure provision tool. With consistent workflows, Terraform allows managing infrastructures throughout their life cycle effectively. On top of all, Terraform will manage all types of resources, from storage, computing, and networking to DNS entries and SaaS features.

The tutorial ahead will walk you through IaC, the functioning of Terraform, different editions of Terraform, common use cases of Terraform, features of Terraform CLI and Cloud, and many more.

Table of Content - Terraform Tutorial

What is IaC?

How does Terraform Function?

➤ Why Terraform?

➤ What are the Editions of Terraform, and brief them a bit?

➤ What are the Common Use-Cases for Terraform?

➤ What are the features of Terraform CLI?

➤ What are the Features of Terraform Cloud?

➤ How are Installation and Administration Managed in Terraform Enterprise?

➤ How to install Terraform on the Windows platform?

➤ How to Change Infrastructure using Terraform in AWS platform?

What is IaC?

IaC is the tool that can manage the complete IT infrastructure of your systems using human-readable files. You can automate the entire data center using programming scripts. It includes infrastructure management, configuration management, version control, automated testing, and deployment automation. This way, Terraform is one of the popular IaC tools increasingly used by many organizations. Mainly, you can automate cloud resources using this tool.

If you want to enrich your career and become a professional in Terraform, then enroll in "Terraform Online Training" - This course will help you to achieve excellence in this domain.

How does Terraform Function?

Terraform connects with external applications through APIs. For this, Terraform providers allow users to access Terraform tools through accessible APIs.

Terraform Function

Core Terraform Workflow: There are three stages in the Core Terraform workflow.

Core Terraform Workflow

Write: At the first stage, the resources and services you need for your application are decided.

Plan: In this stage, Terraform prepares a plan to describe the needed infrastructure based on the existing infrastructure and configuration. And this plan will be implemented only after approval.

Apply: Terraform will execute implementation as per the order described in the plan without neglecting resource dependencies.

Why Terraform?

As mentioned earlier, Terraform is one of the powerful IaC tools widely used across organizations. Let’s discuss the reasons for the same below:

Flexibility: Terraform allows you to use any platform or service from the Terraform Registry. Especially, you don’t need to worry about the upgrades and modifications of services and infrastructure since Terraform will manage everything automatically.

Tracking: Terraform keeps a ‘State file’, which helps to identify the modifications and upgrades made by Terraform as and when.

Automation: Terraform creates resource graphs, including resource dependencies, which will be used to boost the efficiency of provisioning.

Standardizing Configurations: Terraform uses modules that are reusable configurations. With modules, you can save time and encourage best practices.

Collaboration: In Terraform, you can adopt Version Control System since the configuration is usually written in a file. When considering Terraform Cloud, it supports running Terraform in a reliable and consistent environment. It also offers Role-Based Access Control (RBAC), a private registry for sharing modules and providers, and secured access. Therefore, you can use Terraform Cloud to manage Terraform workflows.

MindMajix Youtube Channel

What are the Editions of Terraform, and brief them a bit?

Following are the editions of Terraform:

  • Terraform Open Source or Terraform CLI
  • Terraform Cloud
  • Terraform Enterprise

Let’s learn about them one by one.

Editions of Terraform

Terraform Open Source: It is a free and open-source tool of Terraform, which makes Command-Line Interaction (CLI). With Terraform CLI, you can manage thousands of resources and services. Terraform CLI supports provisioning infrastructure with any Cloud Provider. Not only this, but it also manages configuration, infrastructure, plugins, and state.

Terraform Cloud: It is a SaaS application and supports Terraform to run in a stable and secured environment. Terraform Cloud comes with a rich user interface and RBAC, in addition to providing a private registry for sharing modules and Terraform providers. Considering integration, it integrates with Terraform CLI, GitHub, BitBucket, and GitLab. Moreover, it publishes configuration modules in the Terraform Cloud Private Registry that has approved infrastructure patterns.

Terraform Enterprises: This edition allows self-hosted distribution of Terraform Cloud. In other words, it provides a private instance of Terraform Cloud. It offers customizable resource limits, and strict security and compliance requirements. Apart from all these, Terraform Enterprises allow installations, private networking, sophisticated architecture, and job scaling for performance.

Related Article: Terraform Interview Questions for Beginners

What are the Common Use Cases for Terraform?

Terraform comes up with numerous features, and they all serve in different dimensions. Let's see what their use-cases are as follows:

Infrastructure as Code: With infrastructure as code, automation is simplified in Terraform. Therefore, you can easily automate the provisioning of infrastructures such as servers, firewalls, and databases. In the same way, infrastructure and policies are codified, managed, shared, and executed within a workflow, ensuring consistency all across the infrastructure.

Managing Kubernetes: Kubernetes is the open-source workload scheduler, especially in containerized applications. Terraform supports deploying Kubernetes clusters. On this note, you can manage Cloud and on-premises infrastructure through Kubernetes CRD and Terraform Cloud.

Multi-Cloud Deployment: With multi-cloud deployment, Terraform simplifies large-scale infrastructure. And with this, Terraform manages multiple cloud providers and cross-cloud dependencies effectively. In this regard, Terraform uses AWS Lambda for serverless functions. This way, it manages Microsoft Azure directory resources and load balancers in Google Cloud.

Common Use Cases for Terraform

Deployment, Scaling, and Monitoring Tools: Terraform manages to deploy, scale, release, and monitor infrastructure for multi-tier applications efficiently. In this regard, Terraform keeps each tier of web servers, API servers, database, caching servers, and routing meshes together. Not only this, it manages dependencies between resources effectively. This is why Terraform deploys databases before web servers since both are dependent on each other.

Self-Service Clusters: Terraform deploys infrastructure for organizations smoothly even if there are many requests for resources. With self-service clusters, Terraform allows teams to build infrastructure independently. Know that modules are used to codify the standards of deployment. In return, they ensure that deployment will comply with the practices of an organization.

Policy Compliance and Management: Terraform enforces policies based on the resources that teams should provide and use. In this regard, sentinel, a policy as a code framework, supports enforcing policies before Terraform makes infrastructure changes.

Software-Defined Networking (SDN): Configuring networks can be automatically performed based on the applications running on them, and it happens when Terraform interacts with SDNs actively. In return, deployment times will be reduced significantly by replacing ticket-based workflow with automated workflow. Specifically, CI/CD workflows support automating infrastructure deployments. Moreover, Terraform supports automating key networking tasks such as updating load balancer member pools and applying firewall policies.

Related Article: Private Registry of Terraform

What are the Features of Terraform CLI?

Here, you can find the features of Terraform CLI – one of the editions of Terraform. Let’s have a look at them now.

Initialising Working Directories: Working directories provide content for configuration. Using these directories, you can store modules, caching plugins, settings, and state data. This way, hidden. Terraform directory is used and automatically managed by Terraform. Here, Terraform init command is used to initialize a working directory. Note that you cannot run Terraform plan, and Terraform applies commands without initializing.

Provisioning Infrastructure: Terraform's primary task is to create, modify, and destroy infrastructure resources to match the desired Terraform configuration. Know that provisioning is the core of Terraform tools, and it depends on the three commands such as plan, apply, and destroy. At first, the Terraform plan command evaluates all the resources' desired state. Next, Terraform creates a plan based on the difference between the desired state and the current state. By executing Terraform apply command, Terraform provisions infrastructure to meet the desired state based on the Terraform plan. At last, Terraform destroy command is used to delete resources in the existing configuration as per the requirements.

Authenticating: Terraform integrates with Terraform Cloud, and it could be a front-end or back-end integration. Know that integrations need authentication. For this, Terraform uses login and logout commands to automate the process of using API tokens for Terraform accounts.

Writing and Modifying Codes: Terraform language, which is the primary user interface of Terraform. This is why Terraform workflows depend on this language entirely. Creating Terraform code can be achieved using the following commands – Terraform console command, Terraform validate command, Terraform fmt command, 0.12 upgrade command, and 0.13 upgrade command.

Automating Terraform: When organizations use Terraform as an effective tool for change management, it is better to automate Terraform to get optimum results. Also, Terraform will bring consistency between runs and integration control hooks. With Wrapperscripts and Jenkins, you can achieve automation in Terraform.

Managing Plugins: To manage resources effectively, Terraform uses plugins or providers. Terraform downloads plugins from the source registry based on the needs of configuration. Then, the configuration file of Terraform supports caching the downloaded plugins. And with this, Terraform specifies a local or HTTPS mirror to install plugins.

What are the Features of Terraform Cloud?

Now, we will discuss the features of Terraform Cloud in detail. Let’s start now.

Terraform Cloud allows Terraform to run in a consistent and reliable environment. It allows users to access it together. Moreover, Terraform Cloud provides easy access to shared data, access controls, secret data, policy controls, a private registry, and many more.

Terraform Workflow: Generally, Terraform Cloud runs Terraform CLI for provisioning infrastructure. Terraform provides a team-oriented remote Terraflow workflow designed so that users can easily handle this tool. Not only this, even new learners can quickly adapt to this tool. Know that Terraform workflow has many components such as CLI, remote Terraform execution, version control integration, remote state management, a workspace-based organization model, and a private Terraform module registry.

Integrations: In general, all the features of Terraform cloud are available in APIs. So, other services can create workspaces, upload configurations, configure workspaces, and start Terraform runs. Also, Terraform allows sending notifications to other systems from Terraform Cloud. Besides, Terraform has the feature ’run tasks’ that allows Terraform Cloud to execute tasks in external systems. And it will happen at the specific points of Terraform cloud run cycle.

Access Control and Governance: With Terraform Cloud’s access controls and policies, you can simplify the complexity of the access control of large enterprises. Also, Terraform Cloud allows ‘team-based permission systems’ to ensure the security of resources. Using sentinel policy as a code framework, Terraform Cloud helps restrict the size of compute VMs, streamlines major updates to defined maintenance Windows, and many more. Also, Terraform Cloud makes granular policies for the functioning of organization provisioning. Besides, Terraform Cloud makes effective cost estimations, which will help make changes in infrastructure at your convenience.

How are Installation and Administration Managed in Terraform Enterprise?

Now, let’s discuss the installation and administration processes of Terraform enterprises.

Install and Configure: Before installing Terraform Enterprise version, you must decide on the following things – Operational Mode and data storage, Credentials, and Linux storage. In this regard, the operational mode decides on how data should be stored as well as deployment methods also. Ensure that you have a Terraform Enterprise license and a TLS certificate before installing. Not only this, but you also need to install the Linux instance and the related changes in the configurations.

Administration: There are two domains in Terraform administration: infrastructure administration and application administration. Infrastructure administration executes upgrades, monitoring, and backups. Application administration includes administration tasks and configurations within applications.       

How to Install Terraform on Windows Platform?

Terraform collaborates with many platforms and services such as AWS, Microsoft Azure, Google Cloud, and so on. This tutorial will discuss how to install Terraform in Windows for AWS applications.

Installing Terraform - Manual:

  • Find the appropriate package based on your requirements and download it. Terraform can act as a single binary so that you can replace other files from the downloads.
  • Ensure that Terraform binary is available in your PATH

Installing Terraform - Manual

  • You can verify installation for Windows by opening a new Terraform session. You can use the command Terraform to help to know the available commands. Running this command, you will get the window as below:
  • You can add any subcommands to know more about Terraform. All these, you can understand from the below images.
terraform -help plan


  •  If the window shows any error after the installation, it indicates that the PATH variable was not set up correctly. So, you can verify the PATH once again that includes the directory where Terraform is installed.

Enabling Tab Completion:

  • You can enable tab completion for Terraform commands when using Bash and Zsh.
  • Ensure that a configuration file exists for the selected shell to enable autocomplete
  • First of all, run the following command.
touch ~/.bashrc
  • Then, install the autocomplete package.
terraform - install - autocomplete
  • Once the autocomplete is installed, the shell needs to be restarted.

Installation using Web Browser:

  • At first, create a directory with the name ‘learn-Terraform-docker-container.'
mkdir learn-terraform-docker-container

cd learn-terraform-docker-container
  •  Then, create a file with the name main.tf and paste the following Terraform configuration into the file.

Installation using Web Browser

  • Now, initialize the project with the following command.
terraform init
  • Then, you can provision the NGINX server container with the Terraform apply command. And then, press ‘enter’ to say ‘yes’ to the prompt raised by Terraform.
terraform apply
  • You can verify the existence of the NGINX container either by visiting localhost:8000 in the web browser or running docker ps.
  • If the NGINX server is installed, you will see the below page.

 NGINX server

  • If you want to stop the container, you can run Terraform destroy for the same.
terraform destory

Congrats! You have learned how to provision and destroy an NGINX server with Terraform tool.

How to Change Infrastructure using Terraform in AWS platform?

In this section, we will learn to apply changes to Terraform projects. Once the execution plan is created, it can be applied to modify the infrastructure to achieve the desired state.


  • Install the version – Terraform CLI (0.14.9+) along with AWS CLI.
  • Create a directory with the name ‘learn-Terraform-aws-instance’ and create a file with the name main.tf and paste the below configuration into the file.

Change Infrastructure using Terraform in AWS platform

  • Now, initialize and apply the configuration using the following commands. After that, respond to the confirmation prompt ‘yes’.
terraform init   terraform apply


 You can update the ami of your instance now. Change the aws_instance.app_server resource under the provider block in main.tf by replacing the current AMI ID with a new one.

  • Now, Terraform will destroy the old instance and create a new instance.


Apply Changes:

  • Once the configuration is changed, run Terraform apply to see the changes in the existing resources.
terraform apply
  • Terraform will prompt approval for the execution plan to proceed further. Now, you can enter ‘yes’ to continue with the plans.
  • Here, Terraform destroys the existing instance at first and then creates a new one.

Apply Changes

  • You can use Terraform show command to get the printout of the new values related to this instance.                                                 


We hope that this tutorial provides you with a good idea about Terraform – Infrastructure as a Code – if we are on the same page. To cut the long story into short, you might have learned in detail about Terraform features, different editions, and common use-cases. You should have been trained to install Terraform software and make changes in the infrastructure in the AWS platform through the tutorials provided in the blog. To wrap it off, it's no wonder that any infrastructure can be automatically changed to its required configuration with the Terraform platform's support.

Course Schedule
Terraform TrainingJun 15 to Jun 30View Details
Terraform TrainingJun 18 to Jul 03View Details
Terraform TrainingJun 22 to Jul 07View Details
Terraform TrainingJun 25 to Jul 10View Details
Last updated: 06 Nov 2023
About Author


Madhuri is a Senior Content Creator at MindMajix. She has written about a range of different topics on various technologies, which include, Splunk, Tensorflow, Selenium, and CEH. She spends most of her time researching on technology, and startups. Connect with her via LinkedIn and Twitter .

read less