VNG Cloud Has Successfully Integrated Terraform, Leading The Trend of Infrastructure as Code in Vietnam

2021/06/30 08:37

Infrastructure as Code - The new trend for businesses

In the era of cloud computing technology, enterprises are increasingly relying on cloud server systems, data stores, and IoT applications. With the rapid growth of the market, businesses face the challenge of launching, building, and upgrading products and services in a timely manner. This puts pressure on the IT department to accelerate system deployment and ensure the flexibility of the infrastructure to support operational processes, expansion, and new infrastructure development.

To address these challenges, the introduction of Infrastructure as Code (IaC) has become crucial. It automates the infrastructure configuration process, enabling businesses to deploy systems quickly. One of the most popular tools for Infrastructure as Code is Terraform, an open-source tool that allows for building, editing, and versioning infrastructure in a secure and efficient manner.

Benefits of Terraform

Terraform is a powerful tool used for managing various cloud service providers such as AWS, Azure, Google Cloud, and even VNG Cloud. It enables businesses to efficiently manage a wide range of infrastructure systems, including compute instances, storage, networking, DNS, and SaaS solutions.

By leveraging Terraform, businesses can significantly reduce the time required for system adjustments and deploy technology systems with ease. It also facilitates easy scalability of servers, allowing businesses to quickly adapt to changing demands. Additionally, using Terraform enhances the ability to monitor the entire system, ensuring the safety and security of the infrastructure.

As a pioneer in Vietnam, VNG Cloud has successfully integrated Terraform, providing businesses with the capability to rapidly create and manage networks and servers in an optimal manner.

Mô hình hoạt động Infrastructure As Code
Instructions for integrating Terraform into the vServer system

Let's explore a simple example of using Terraform to provision and manage multiple vServers simultaneously on the VNG Cloud platform.

Here are the steps to follow:

Step 1: Install Terraform. You can follow the detailed installation instructions here. Once installed, you can verify the successful installation by running the command terraform --help.

Step 2: Download the example files named and from the VNG Cloud repository. Alternatively, you can create these files in a directory on your machine, for example, terraform-vngcloud. Terraform uses .tf files to define your infrastructure configurations.

  • This file contains the code snippets to create desired resources. For example, the following code snippet will instruct Terraform to provision a vServer Instance:

resource "vngcloud_vserver_server" "server"{

count = var.server_count

project_id = var.project_id

name = "vngcloud-server-${count.index}"

encryption_volume = false

attach_floating = true

flavor_id =

image_id =

network_id = var.network_id

root_disk_size = var.root_disk_size

root_disk_type_id =

ssh_key = var.ssh_key_id

security_group = var.security_group_id_list

subnet_id = var.subnet_id

action = "start"

lifecycle {

create_before_destroy = true



  • This file contains the variables used in the file above. You need to modify these information according to your needs, such as server configuration, disk configuration, operating system, SSH key, etc. Additionally, you can specify the number of vServers to be provisioned using the server_count variable. For example, here we specify that 10 vServers will be provisioned simultaneously.

variable "image_name" {

type = string

default = "1-Ubuntu-18.04x64"


variable "flavor_zone_name" {

type = string

default = "General v1 Instances"


variable "flavor_name" {

type = string

default = "v1.small1x1.b100"


variable "volume_type_name" {

type = string

default = "SSD-IOPS3000"


variable "root_disk_size" {

type = number

default = 20


variable "data_disk_size" {

type = number

default = 50


variable "server_count" {

type = number

default = 10



Step 3: After configuring the information in the tf file, you need to run the terraform init command to initialize Terraform and download the VNG Cloud provider, while setting up the necessary information.

Step 4: Run the terraform plan command to check and preview the resources that will be created or changed.

Step 5: Run the terraform apply command to perform the vServer provisioning using the specified tf files through Terraform. Congratulations, you have successfully provisioned 10 vServers with Terraform.