Now that you understand the basics of Infrastructure as Code (IaC), this topic explains what Terraform is.
What is Terraform
Terraform is an open source IaC tool from HashiCorp. It lets you define Alibaba Cloud resources using declarative configuration files.
Terraform manages foundational components, such as virtual machines, containers, storage, and networks. It also manages configuration components, such as security group rules, DNS entries, and access policies. Additionally, it can manage certain Software as a Service (SaaS) features.
Terraform uses a simple, human-readable language called HashiCorp Configuration Language (HCL) to define infrastructure as code. Terraform reads your configuration files and creates an execution plan. You can then preview, confirm, and execute this plan to create and manage your infrastructure.
Alibaba Cloud provides a Terraform Provider for its resources. You can use this provider to define and author Alibaba Cloud resources, and then create those resources automatically.
Features of Terraform
The features of Terraform include the following:
Multicloud and multi-API support: In addition to Alibaba Cloud, Terraform supports all major cloud service providers. It also supports other services through their APIs, such as GitHub and Kubernetes.
Open core architecture: It offers three versions, from self-hosted to fully managed, with enterprise-level support.
Large community: It has a large community and an open registry. This registry supports the online registration and management of all providers and modules, including those for Alibaba Cloud.
Infrastructure configuration: Refers to managing the lifecycle (creation, modification, deletion, and viewing) of infrastructure resources, rather than managing the configuration of the infrastructure system itself, such as starting services, installing dependencies, installing applications, and running updates.
Terraform on Alibaba Cloud provides the following capabilities:
Resource configuration: You can use Terraform to define and configure Alibaba Cloud resources, such as virtual machines, networks, storage, and firewalls, using resource blocks.
Resource dependency creation: You can create explicit dependencies between resources to ensure that they are created in the correct order.
Standardized modules: You can standardize resource creation by building reusable modules. Alibaba Cloud also provides standard modules that you can reference directly.
IaC workflow
The following steps describe the standard IaC workflow.

Scoping
Before you start the Terraform workflow, determine which resources your project or application needs. For example, a common two-tier architecture requires a web server pool and a database. In the scoping phase, you identify the necessary Alibaba Cloud resources and plan how they are connected.
Authoring
The Terraform workflow starts with authoring. You write the code for your desired infrastructure and organize it into different configuration files, such as `main.tf`, `variables.tf`, and `tfvars`.
Initialization
In the initialization phase, any plugins or modules required by your code are automatically installed. You run the `terraform init` command, which initializes the Terraform working directory and installs the Alibaba Cloud Terraform Provider.
Preview
In the planning phase, you run the `terraform plan` command. This command creates an execution plan to create, modify, or destroy resources based on your configuration. You can review the plan before you apply it to your Alibaba Cloud infrastructure to make sure that it matches your expectations.
Applying
After you review the execution plan, you run the `terraform apply` command. This command creates, modifies, or destroys your infrastructure and creates a corresponding state file or updates the existing state file.
You will explore the Terraform workflow in more detail as you continue with these tutorials.
Scenarios
This section describes some common scenarios for using Terraform.

Manage infrastructure
Terraform manages infrastructure using an immutable approach. This approach reduces the complexity of upgrading or modifying services and infrastructure.
Track changes
Terraform tracks infrastructure changes and requires your confirmation before it previews or applies them. When Terraform creates infrastructure, it automatically generates a state file. This file reflects the current state of your infrastructure and shows the number and type of Alibaba Cloud resources that are modified in your configuration template.
Automate changes
Terraform automates changes because its configuration files are declarative. You do not need to write detailed instructions to build your infrastructure. Instead, you define the final state, and Terraform automatically manages dependencies and provisions the resources.
Standardized configuration templates
You can standardize configurations using custom modules or public modules from the Terraform Registry to improve efficiency and follow best practices. Terraform also supports automated policy enforcement, which lets you constrain the resource types that your team can configure and use.