Introduction to Hashicorp-Terraform for Beginners

Terraform

Terraform is an open-source IaC (Infrastructure-as-Code) tool for configuring and deploying cloud infrastructure. It codifies infrastructure in configuration files that describe the desired state for your topology. Terraform allows you to use a consistent workflow over your infrastructure lifecycle, regardless of the resource provider. The infrastructure as code workflow lets you declaratively manage a variety of services and automate your changes to them, reducing the risk of human error through manual operations.

Advantages

  1. IAC is crucial because it helps to speed the deployment and release of the software.
  2. Terraforms support provides multi-cloud platforms like AWS, AZURE, Google, etc.
  3. IAC assists in restricting users from deleting resources accidentally.
  4. Provide a template to write code and use it many times.
  5. Unified templates also provide security.

Setup Terraform

Workflows

In HCP Terraform, your resources are organized by workspaces, which contain your resource definitions, environment and input variables, and state files. A Terraform operation occurs within a workspace, and Terraform uses the configuration and state for that workspace to modify your infrastructure.

HCP Terraform supports three workflows for your Terraform runs.

  1. The CLI-driven workflow uses Terraforms standard CLI tools to execute runs in HCP Terraform.
  2. The UI/Version Control System(VCS)-driven workflow, in which changes pushed to version control repositories trigger runs in the associated workspace.
  3. The API-driven workflow allows you to create tooling to interact with the HCP Terraform API programmatically.

Terraform Basic command

  1. Init: Validate working directory consisting of terraform config file. This is the first command to be executed after writing a new file.
  2. Validate: Check for syntax and validate the config file.
  3. Plan: Create an execution plan.
  4. Apply: Apply changes and execute the command to create resources.
  5. Destroy: Remove terraform managed resources. It will ask for confirmation before removing resources.
Next Recommended Reading Introduction To Atlassian Bitbucket