System Provisioning Management tool (Terraform) and its 5 popular command
By: Rachit Chauhan
Tags: Iac, AWS, Commands, Terraform

Firstly, let’s discuss What is Terraform?

Terraform is an open source Infrastructure as Code tool which is created by HarshiCorp. It is currently the most popular automation tools available.

Terraform is a declarative coding tool which enables the developers to use a high level configuration language called HCL (HashiCorp Configuration Language) to describe the desired end state cloud or on premises infrastructure for running the application. It then generates a plan for reaching that end state and executes the plan to provision the infrastructure.

Terraform uses a Simple syntax, it can provision infrastructure across multiple cloud on premises data centers and can efficiently re-provision infrastructure in response to configuration changes.

This is how Terraform Script look like Source: HashiCorp

Infrastructure as Code

Infrastructure as Code (IaC) allows developers to codify infrastructure in a way that makes provisioning automated, faster, and repeatable. It’s a key component of Agile and DevOps practices such as version control, continuous integration and continuous delivery.

Now the other question that might arises is Why Terraform?

There are few reasons that why developers terraform instead of using other infrastructure as code tools:

Open source: Terraform is backed by large communities of contributors who build plugins to the platform. Regardless of which cloud provider you use, it’s easy to find plugins, extensions, and professional support. This also means Terraform evolves quickly, with new benefits and improvements added consistently.

Terraform is backed by large communities of contributors who build plugins to the platform. Regardless of which cloud provider you use, it’s easy to find plugins, extensions, and professional support. This also means Terraform evolves quickly, with new benefits and improvements added consistently. Platform agnostic: Meaning you can use it with any cloud services provider. Most other IaC tools are designed to work with single cloud provider.

5 popular command of Terraform:

1.Terraform init: The terraform init command is used to initialize the working directory in which the terraform configuration files are present these files includes such as main.tf, variables.tf etc. This is the first command that should be run after writing a new terraform configuration or cloning an existing one from version control.

Command: terraform init [options] [dir]

2. Terraform plan: The terraform plan command is used to create an execution plan. Terraform performs a refresh, unless explicitly disabled, and then determines what actions are necessary to achieve the desired state specified in the configuration files.

Command: terraform plan [options] [dir]

3. Terraform apply: The terraform apply command is used to apply the changes required to reach the desired state of the configuration, or the pre-determined set of actions generated by a terraform plan execution plan.

Command: terraform apply [options] [dir-or-plan]

4. Terraform import: The terraform import command is used to import existing resources into Terraform.

Command: terraform import [options] ADDRESS_ID

5. Terraform destroy: The terraform destroy command is used to destroy the Terraform-managed infrastructure.

Command: terraform destroy [options] [dir]

References:

https://www.ibm.com/cloud/learn/terraform#toc-why-terraf-wuz4eNQo