By Gavaskar S., Alibaba Cloud MVP
Infrastructure as code is an approach to define and build infrastructure components, such as networks, virtual machines, and service load balancers through machine-readable definition files rather than physically creating the hardware. It reduces the time and cost spent on the software development process while increasing the quality and overall customer experience. There are various infrastructure as code automation tools, such as Terraform, Ansible, Puppet, and Chef.
In this blog, we are going to see how to create a Virtual Private Cloud network (VPC) on Alibaba Cloud through Terraform Cloud.
Terraform is an open-source orchestration tool by HashiCorp. It was developed using the Go Language, and the source code is available in GitHub. It makes us write the declarative configuration of the infrastructure in a text file and can be used to plan, setup, change, and destroy the infrastructure safely and efficiently. The various advantages of using Terraform are:
Terraform Cloud is a SaaS application that makes the team collaborate and work together for a single project/application. Terraform Cloud is available as a hosted service at https://app.terraform.io. It offers free accounts for small teams and paid plans with additional feature sets for medium-sized businesses.
GitHub is a huge repository that provides developers with a web-based graphical interface tool for shipping code through a pull request and code review. It consists of a collaboration of 15 million developers all over the world.
Figure 1: The Steps in Creating VPC Using Terraform Cloud
Create a repository in GitHub. Then, add the statement below to create a VPC named tcloud-resource
and a Vswitch named subnet-tcloud
.
terraform {
required_providers {
alicloud = {
source = "hashicorp/alicloud"
version = "1.93.0"
}
}
}
resource "alicloud_vpc" "vpc" {
name = "tcloud-resource"
cidr_block = "10.0.0.0/16"
}
resource "alicloud_vswitch" "vsw-web" {
name = "subnet-tcloud"
vpc_id = alicloud_vpc.vpc.id
cidr_block = "10.0.1.0/24"
availability_zone = "ap-southeast-1a"
}
Resource Access Management (RAM) is an Alibaba Cloud Service that can create multiple users with particular resource access permission. Now, you have to create a RAM user with an Access Key ID and an Access Key Secret. While creating, remember to check the Programmatic Access in the RAM Console.
First, you have to create an account using this URL https://app.terraform.io/. Provide your username, email, password, and your organization name to sign up. Then, follow the steps below to create a workspace and link your GitHub repository with the Terraform Cloud.
Step 3.1: In the dashboard of the Terraform Cloud, click "New Workspace" to create a new workspace
Step 3.2: Choose the corresponding workflow that needs to be created. Here, I have selected a version control workflow.
Step 3.3: Connect to the repository/version control provider by providing the authentication details, such as your username and password. Here, I have chosen GitHub.
Step 3.4: Choose the corresponding repository where the terraform file resides. Here, I have chosen terraform.
Step 3.5: Create a workspace by clicking "Create workspace"
Step 3.6: After the workspace is created successfully, you have to configure the region where you are going to create the VPC, Access Key ID, and Access Secret ID of the RAM user, which we created in Step-2.
Step 3.7: To display the terraform plan, click "Query plan"
Step 3.8: Finally, run the terraform by clicking "Confirm and Apply". Now, you can see the VPC with the configuration specified in the terraform file is created in your Alibaba Cloud account.
Terraform is one of the important configuration management and infrastructure tools. GitHub is the source code management and versioning tool used in DevOps Automation. In this blog, I have explained how Terraform Cloud can be leveraged to create a VPC in Alibaba Cloud.
Experiencing the Sixth-Generation Enhanced Type Elastic Compute Service (ECS) Instances
12 posts | 3 followers
FollowAlibaba Cloud Community - June 12, 2023
Alibaba Cloud Community - July 18, 2022
Alibaba Cloud Serverless - February 28, 2023
Alibaba Cloud Community - August 3, 2022
Alibaba Clouder - August 9, 2018
Alibaba Cloud Indonesia - June 18, 2024
12 posts | 3 followers
FollowRobotic Process Automation (RPA) allows you to automate repetitive tasks and integrate business rules and decisions into processes.
Learn MoreAccelerate software development and delivery by integrating DevOps with the cloud
Learn MoreAlibaba Cloud offers an accelerated global networking solution that makes distance learning just the same as in-class teaching.
Learn MoreAn enterprise-level continuous delivery tool.
Learn MoreMore Posts by GAVASKAR S
Amuthan Nallathambi March 11, 2021 at 3:26 pm
Excellent