By He Guimin, nicknamed Xiaozhu at Alibaba.
This is the first of a series of articles on Terraform that covers multiple aspects of Terraform, including its major concepts, features, working mechanisms, usage, and best practices, to describe how to use Terraform on Alibaba Cloud. As an introduction to this series, this article begins by describing what exactly Terraform is.
Two years ago, if you had asked people what Terraform was, there might not have been very many people familiar with it. After all, it was first released in 2014. When it comes to resource orchestration, products like Alibaba Cloud Resource Orchestration Service (ROS) come quicker to our minds. However, if you ask "What is Terraform?" today, I believe that most people are no strangers to it, and some companies and several interested developers have already started to use Terraform to manage their infrastructure. Whether it is due to the official promotion by Hashicorp or the promotion by Alibaba Cloud Yunqi (Apsara) Community, the continuous development of DevOps or the increasing popularity of cloud native, the support from Alibaba Cloud alone at the beginning or the follow-up support from other domestic cloud service providers, Terraform has been more widely mentioned in China and elsewhere over the past two years.
In the past, multiple Yunqi articles have introduced what Terraform is. This article will combine the information covered in these articles along with the information covered by Terraform's official documentation to list and summarize the introductions offered by these articles.
In 2014, Hashicorp launched a product called Terraform.
The official definition of Terraform is as follows:
Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.
Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans, which can be applied.
The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries and SaaS features.
To be more brief, the definition of Terraform can be summarized in three sentences:
More generally, Terraform is an open-source automated O&M tool used for resource orchestration that runs on a client. It defines resources to be managed in the template in the form of code, and automatically creates, changes, and manages the defined resources by parsing and executing the template to reach the goal of automated O&M.
Terraform has the following features:
resource "alicloud_instance" "instance" {
count = 5
instance_name = "my-first-tf-vm"
image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
instance_type = "ecs.sn1ne.small"
security_groups = ["sg-abc12345"]
vswitch_id = "vsw-abc12345"
tags = {
from = "terraform"
}
}
terraform plan
command to generate an executable plan by parsing the template. This plan displays the resources to be created or changed in the current template and their attributes. You can preview this plan. After confirming that it is correct, run the terraform apply
command to quickly create and change the defined resources to avoid unexpected problems.An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# alicloud_instance.instance[0] will be created
+ resource "alicloud_instance" "instance" {
+ availability_zone = (known after apply)
+ id = (known after apply)
+ image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
+ instance_name = "my-first-tf-vm"
+ instance_type = "ecs.sn1ne.small"
+ security_groups = [
+ "sg-abc12345",
]
+ tags = {
+ "from" = "terraform"
}
+ vswitch_id = "vsw-abc12345"
...
}
# alicloud_instance.instance[1] will be created
+ resource "alicloud_instance" "instance" {
...
}
# alicloud_instance.instance[2] will be created
+ resource "alicloud_instance" "instance" {
...
}
...
Plan: 5 to add, 0 to change, 0 to destroy.
As a powerful DevOps tool, Terraform greatly reduces the cost of infrastructure management. Its convenience and advantages will be more and more prominent with the increasing complexity of business architecture, infrastructure resources, and the relationship among the resources in the future.
With the rapid development of cloud computing, Terraform is favored by an increasing number of cloud service providers and other software service providers. Currently, Terraform provides a total of more than 100 Providers and Provisioners, and supports 15 Backend Types. As the first cloud service provider in China to integrate with Terraform, Alibaba Cloud has already provided 138 resources and 92 data sources. These resources and data sources cover many area, such as the computing, storage, networking, load balancing, content delivery network (CDN), middleware, access control, and databases. And from Terraform 0.12.2, Alibaba Cloud Object Storage Service (OSS) began providing remote state storage as a standard remote state backend to further improve the user experience and reduce costs.
The views expressed herein are for reference only and don't necessarily represent the official views of Alibaba Cloud.
Managing Alibaba Cloud Resources in Ansible Using Dynamic Inventory
2,599 posts | 762 followers
FollowAlibaba Clouder - September 10, 2020
JDP - July 31, 2020
Alibaba Cloud Indonesia - June 18, 2024
Alibaba Clouder - May 23, 2018
JDP - September 2, 2021
Alibaba Cloud Native Community - November 16, 2022
2,599 posts | 762 followers
FollowAccelerate software development and delivery by integrating DevOps with the cloud
Learn MoreAn enterprise-level continuous delivery tool.
Learn MoreConnect your VPCs to services in other VPCs through secure, reliable, and private connections.
Learn MoreRespond to sudden traffic spikes and minimize response time with Server Load Balancer
Learn MoreMore Posts by Alibaba Clouder