Terraform is an infrastructure as code (IaC) tool that you can use to preview, configure, and manage the infrastructure and resources of cloud services in a secure and efficient manner. Serverless App Engine (SAE) allows you to use Terraform to manage your SAE resources in a more secure manner and implement continuous integration or continuous delivery (CI/CD) by using GitOps.
Introduction
Basic features
Terraform is a tool that supports the automated orchestration of IT infrastructure. Terraform allows you to use code to manage and maintain IT resources. For more information, see What is Terraform?
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 can be integrated with the Alibaba Cloud provider to support new infrastructures. You can use a template to configure the Alibaba Cloud provider to 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).
For more information about how to integrate Alibaba Cloud services with Terraform, see Alibaba Cloud Provider.
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.
Benefits
Terraform provides the following benefits in common scenarios:
Terraform provides the following benefits that are specific to SAE:
Declarative infrastructure as code (IaC)
Terraform allows you to deploy, scale in or out, upgrade or downgrade, and start or stop applications. You can also use Terraform to bind SLB instances with applications.
Terraform allows you to write code without the need to understand the SAE API.
Terraform supports CI/CD to improve SAE performance on automatic application delivery.
Terraform ecosystem
Terraform provides the LiveDiff capability, which allows you to manage your SAE resources with high security.
Terraform helps you deploy SAE applications to the desired state in a stable manner.
Terraform provides the resource orchestration capability, which allows you to efficiently deploy SAE applications and dependent resources with a few clicks.
Categories
Resources
Each resource is a newly created resource. For more information, see Resources.
The following sample code provides an example on how to create an SAE application:
resource "alicloud_sae_application" "default" { app_description = "tf-testaccDescription" app_name = "tf-testaccAppName" namespace_id = alicloud_sae_namespace.default.id image_url = "registry-vpc.cn-hangzhou.aliyuncs.com/lxepoo/apache-php5" package_type = "Image" vswitch_id = alicloud_vswitch.vsw.id timezone = "Asia/Beijing" replicas = "5" cpu = "500" memory = "2048" }
Data sources
You can query a data source to obtain the information about existing resources and the attributes of the resources. For more information, see Data Sources.
The following sample code provides an example on how to list SAE namespaces:
data "alicloud_sae_namespaces" "nameRegex" { name_regex = "^my-Namespace" } output "sae_namespace_id" { value = data.alicloud_sae_namespaces.nameRegex.namespaces.0.id }
For more information about the examples on how to use Terraform to manage SAE resources, see Use Terraform to manage SAE resources.
Use Terraform to manage SAE resources
The following tables describe the SAE resources that you can manage by using Terraform.
Resource type | Description |
Queries the information about an SAE namespace. For more information, see Use Terraform to manage SAE namespaces. | |
Queries the information about an SAE application. For more information, see Use Terraform to manage SAE applications. | |
Queries the information about an auto scaling policy of SAE. For more information, see Use Terraform to manage an auto scaling policy for an SAE application. | |
Queries the information about an SAE ConfigMap. | |
Queries the information about a canary release rule of SAE. | |
Queries the information about an Ingress instance of SAE. | |
Queries the information about an Internet-facing SLB instance of SAE. For more information, see Use Terraform to associate an SAE application with an SLB instance. | |
Queries the information about an internal-facing SLB instance of SAE. |
Resource type | Description |
Activates SAE. | |
Lists SAE namespaces. | |
Lists SAE applications. | |
Lists the auto scaling policies of SAE. | |
Lists SAE ConfigMaps. | |
Lists the canary release rules of SAE. | |
Lists the Ingress instances of SAE. | |
Lists the instance types of SAE. |