Terraforming Alibaba Cloud - Resource Management 
Tags: terraform, alibabacloud, devops
Published: 2021-04-18 08:18:07

Cloud services categorization and management can be challenging if resources are not tagged and group properly. This is the first post in the Alibaba Cloud Weekly series. 

In this blog post, the Alibaba Cloud Resource Management service is explained with Terraformation and provision. 

When starting with Alibaba Cloud, a default Resource Management group is created. However, keeping all the resources in the default group can be messy. One can create a Resource Management group separated by Department, Functional Group, or Environment. 

Following Terraform code can help in creating a new Resource Management group called "dev". For future posts, the same group will be used. 

For the current solution following two files are created. (upcoming blog posts will use modules)
```
.
├── terraform.tf
└── terraform.tfvars
```

terraform.tf : 
```
variable "access_key" {}
variable "secret_key" {}
variable "region" {}

terraform {
  required_providers {
    alicloud = {
      source  = "aliyun/alicloud"
      version = "1.121.1"
    }
  }
}

provider "alicloud" {
  access_key = var.access_key
  secret_key = var.secret_key
  region     = var.region
}

resource "alicloud_resource_manager_resource_group" "development-rg" {
  resource_group_name = "aliyun-development-rg"
  display_name        = "aliyun-development-rg"
}
```
terraform.tfvars : ( [To generate access and secret keys](https://partners-intl.aliyun.com/help/doc-detail/116401.htm) 
 [For Regions](https://www.alibabacloud.com/help/doc-detail/40654.htm) )
```
access_key            = "SOMEACCESSKEY"
secret_key            = "SOMESECRETKEY"
region                = "SOMEREGION"
```
On successful, a new resource management group should be visible as follows. 

![Resource Manager : After Deployment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ismi33h5nyur9nbjehyj.png)

As stated earlier, the Resource Management Group is a one-stop location to find all the resources created for a particular group. 

![Resource Management Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/amx53v5othrhqtvc2nrk.png)
 
While using Terraform for the next post, the resource group will be specified. Any resources created without resource group directive are created under the "Default" resource group. 

Note that there a soft limit on the Resource Management Group. Any account can have a maximum of 30 Groups, and this limit can be extended by opening a service limit increase ticket. 

Permissions can be set for each resource group to provide more granular access. 

![Permission-Resource Management](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t5miv7p9rsf91nvt9rgh.png)
 
Terraform Provider Reference: [https://registry.terraform.io/providers/aliyun/alicloud/latest/docs](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs)

Do let us know your feedback in the comment box below. Also do let us know if you want us to explore any other Alibaba Cloud services. 

Next week we will add a VPC and VSwitch creation under the newly created Resource Management group. 

If you are new to Terraform and want us to create a post for it then do let us know in the comment section below.