Community Blog Taking full Advantage of Terraform for Managing Resource

Taking full Advantage of Terraform for Managing Resource

In this blog, you will learn what Terraform is, why to use it, and how to install it on Alibaba Cloud for managing cloud resources.

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:

  1. Terraform is a tool that can securely and efficiently build, change, and version management infrastructure. It can also provide custom solutions while managing popular service providers.
  2. Terraform is driven by configuration files that define the components (infrastructure resources) to be managed. Then Terraform generates an executable plan and executes this plan to create, incrementally change, and continuously manage the defined components. If this plan cannot be executed, an error is returned.
  3. Terraform not only can manage IaaS-level resources, such as computing instances, network instances, and storage instances, but also it can also manage higher-level services, such as DNS records and features of SaaS applications.

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.

Learn the main features of Terraform, you can refer to Getting Started with Terraform with Alibaba Cloud: What is Terraform?.

Related Blogs

Five Reasons Why Your Business Should Use Terraform to Deploy on the Cloud

In this blog, we'll fully explore Terraform's capabilities and discuss the reasons why you should consider using it for your business.

If you're working in the IT sector, you've probably heard some of the hype surrounding Terraform by HashiCorp. But what exactly are Terraform's capabilities, and why should your business consider using it?

Put simply, Terraform is powerful infrastructure as code (IaC) tool that allows you to create, update, and control versioning of cloud infrastructure. With Terraform, you can generate and execute plans based on your desired end state and re-provision infrastructure based on configuration changes.

These are all great capabilities, but where Terraform really comes into its own is scenarios involving hybrid cloud and multicloud deployments. In days gone by, managing infrastructure deployed on different cloud providers as well as local data centers could quickly turn into a logistical nightmare, requiring great amounts of time and creating high operations costs. Terraform is an effective solution to this issue, allowing administrators to rapidly deploy and reconfigure infrastructure all from one place, and all at the same time. It is this ability especially that makes Terraform so powerful.

Five Benefits of Using Terraform

So now you know what Terraform is and how it works in practice on Alibaba Cloud. Without further digression then, here are the top 5 reasons why you should start using Terraform today:

1) Improve multi-cloud infrastructure deployment

Terraform applies to multi-cloud scenarios, where similar infrastructure is deployed on Alibaba Cloud, other cloud providers, or local data centers. Developers can use the same tool and configuration file to simultaneously manage the resources of different cloud providers.

2) Automated infrastructure management

Terraform can create configuration file templates to define, provision, and configure ECS resources in a repeatable and predictable manner, reducing deployment and management errors resulting from human intervention. In addition, Terraform can deploy the same template multiple times to create the same development, test, and production environment.

3) Infrastructure as code

With Terraform, you can use code to manage and maintain resources. It allows you to store the infrastructure status, so that you can track the changes in different components of the system (infrastructure as code) and share these configurations with others.

4) Reduced development costs

You can reduce costs by creating on-demand development and deployment environments. In addition, you can evaluate such environments before making system changes.

5) Reduced time to provision

Traditional click-ops methods of deployment used by organizations can take days or even weeks, in addition to being error-prone. With Terraform, full deployment can take just minutes. For example, you can provision multiple Alibaba Cloud services at a time in a standardized way. Both brand new deployments and migrations can be done quickly and efficiently.

Install Terraform in Three Simple Steps

In this blog, we'll show you how to download and install Terraform to take full advantage of its capabilities.

Terraform by HashiCorp is powerful infrastructure as code (IaC) tool that allows you to create, update, and control versioning of cloud infrastructure.

In the last blog, I discussed the incredible benefits of Terraform and how it can allow businesses to provision and manage cloud resources more efficiently than was previously possible. Now it's time to learn how to download and install Terraform so that you can begin to take advantage of its awesome capabilities.

Terraform is available in both an open source and enterprise version, and is fully integrated with all major cloud providers. Key use cases include performing orchestration on a large heterogeneous system that involves multi-cloud and hybrid cloud platforms, and scaling up and down the infrastructure according to variable online workloads.

variable online workloads

There are three steps to completing the installation. After that, you'll be ready to plan your resources and deploy them at the click of a button.

Note that the following steps are taken from the related Best Practice document found on the Alibaba Cloud website. This tutorial walks you step-by-step through the procedure to set up Terraform and then use it to deploy cloud infrastructure. This is a great way to learn the basics of how to use Terraform. Although you'll need to register or log in to view the full document, the usefulness of it means it is well worth the effort.

Step 1: Download the Terraform installation package

When you download the installation package, select a version that suits your system configuration. In our example, we install Terraform 0.11.1 on a Mac OS 64-bit computer as an example. The steps to be performed on Linux are similar to the steps described here.

1) Visit the Terraform official website:


2) Select a version that suits your system configuration.

In this example, we click the download older versions of Terraform link and then select the 0.11.1 version.

Deploy Alibaba Cloud Resources by Using Terraform

In this blog, you can follow detailed steps to learn how to deploy Alibaba Cloud resources by using Terraform.

Terraform is a powerful tool in your orchestration armory, and allows you to create, update, and control versioning of cloud infrastructure.

Terraform provides benefits that include automated infrastructure management, lower deployment costs, and reduced provisioning time. In particular, Terraform comes into its own when it comes to managing hybrid cloud or multi-cloud infrastructure, since it enables developers to use the same tool and configuration file to simultaneously manage the resources of different cloud providers.

In this blog, we'll go through the detailed steps required to deploy cloud infrastructure by using Terraform, taking Alibaba Cloud services as an example. The higher level steps are as follows:

  1. Plan the resources you want to deploy
  2. Inspect the Terraform configurations
  3. Apply the configurations to deploy the services
  4. Verify the infrastructure is deployed in the Alibaba Cloud console

Note that the following steps are taken from the related Best Practice document found on the Alibaba Cloud website. This tutorial walks you step-by-step through the procedure to set up Terraform and then use it to deploy cloud infrastructure.

Before You Begin

Before you get started, you need to make sure that Terraform is downloaded and installed on your system. You can refer to the previous blog article to learn how to do this.

If you're relatively new to Terraform, I also recommend that you read the blog article detailing the benefits of Terraform so that you have a better idea of what it can do for your business.

Step 1: Plan the Resources You Want to Deploy

The first step is to decide which resources you need to deploy, and what the service configurations should be. In this example, we will create a system that runs on multiple Alibaba Cloud services.

Step 2: Inspect the Terraform Configurations

The next step is to create configuration files or check that your existing configuration files are correct. In this example, we use a configuration file that is already created in a demo kit

Related Products

Simple Application Server

One-stop management console simplifies operations including domain name resolution, application deployment and server management.

Elastic Compute Service

On top of the world-class customized components from our various vendors such as Intel, Alibaba Cloud invested heavily on the Research & Development of our ECS product. Over the time, we developed X-Dragon compute platform, including the self-developed SOC, hardware acceleration card, as well as the Dragonfly lightweight hypervisor.Our Technology leadership provides a foundation for the high performance, availability, elasticity, scalability and security you enjoyed in our ECS products.

Related Documentation

Use Terraform to manage OSS

This topic describes how to install, configure, and use Terraform to manage OSS.

Install and configure Terraform

Before you use Terraform, perform the following steps to install and configure Terraform:

  1. Download the software package applicable to your operating system from Download Terraform.
    In this topic, Terraform is installed and configured in a Linux operating system as an example.
  2. Decompress the package to the /usr/local/bin directory.
    To decompress the executable file to another directory, you must add the path to global variables.
  3. Run Terraform to verify the path configuration. If a list of available Terraform options is displayed, the installation is complete.
[root@test bin]#terraform
Usage: terraform [-version] [-help] <command> [args]

Use CLI and Terraform to manage Alibaba Cloud resources

The Alibaba Cloud Cloud Shell is pre-installed with Alibaba Cloud CLI, Terraform, and other management tools. You can manage your paid Alibaba Cloud resources and services through these tools.

1. Cloud Shell management tool

The Cloud Shell is a management tool that is created based on Alibaba Cloud’s open APIs. With this tool, you can call Alibaba Cloud’s open APIs to manage your Alibaba Cloud services. Using the Cloud Shell with Alibaba Cloud’s open APIs achieves flexibility and scalability. You can mount the Cloud Shell to Alibaba Cloud’s built-in APIs to expand the functions you want.

Related Courses

How to Achieve Automated Cloud Resource Orchestration with Terraform

This course introduces the concepts related to resource configuration & orchestration automation, and installation and configuration of the popular resource automation tool terraform. Through the actual operation demo, you will learn how to use terraform to achieve automatic configuration and orchestration of application resources based on Alibaba Cloud platform.

Provisioning a Multi-zone ACK Kubernetes Cluster Using Terraform

Through this course, you will not only learn about Alibaba Cloud Container Service for Kubernetes and its applicable scenarios, but also learn how to use Terraform to flexibly deploy of ACK clusters and realize blue and green deployment.

0 0 0
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like