Terraform
Platform for AI (PAI) supports Terraform, which lets you manage PAI resources.
Background information
Basic features
Terraform is an infrastructure as code (IaC) tool. It lets you define and configure cloud infrastructure by writing simple code, which eliminates the need for manual operations. For more information, see the Terraform product introduction.
Terraform provides an easy-to-use CLI that allows you to deploy configuration files on the workloads of Alibaba Cloud services or third-party cloud services and manage the versions of the configuration files. Terraform allows you to define the infrastructure resources that are required to build cloud topologies in configuration files. The resources include virtual machines (VMs), storage accounts, and network interfaces.
Terraform supports new infrastructure through providers. This lets you use a simple template language to easily define, preview, and deploy cloud infrastructure on Alibaba Cloud.
Terraform allows you to create, modify, and delete the resources of multiple Alibaba Cloud services, such as Elastic Compute Services (ECS), Virtual Private Cloud (VPC), ApsaraDB RDS, and Server Load Balancer (SLB).
Scenarios
Terraform allows you to define infrastructure as code and use code to create, query, modify, and delete infrastructure resources. For information about the examples on how to use Terraform to manage the resources of Alibaba Cloud services, see Scenarios.
Install and configure Terraform
Only Terraform 1.241.0 and later versions support PAI resource management.
Method 1: Cloud Shell.
Method 2: Install and configure Terraform locally.
Method 3: Use Terraform in Terraform Explorer.
Manage PAI resources using Terraform
The following table lists the PAI resources that you can manage with Terraform.
Resource type | Description |
Deploy as an EAS Service | |
Create a code build | |
Create a dataset | |
Create a dataset version | |
Create a flow task | |
Create an algorithm component task | |
Create a workspace |
The following example shows how to use Terraform to create a workspace with alicloud_pai_workspace_workspace.
Create a terraform.tf file, enter the following content, and save the file in the current execution directory.
resource "alicloud_pai_workspace_workspace" "default" { description = "example_terraform_workspace" workspace_name = "example_terraform_workspace" display_name = "example_terraform_workspace" env_types = ["prod"] }Run
terraform initto initialize Terraform and download the required plugins.Run
terraform applyto create the resources.Run
terraform showto view the created workspace.Alternatively, you can log on to the PAI console to view the created workspace.