All Products
Search
Document Center

Serverless App Engine:Terraform overview

Last Updated:Jan 30, 2024

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.

    Table 1. Resources

    Resource type

    Description

    alicloud_sae_namespace

    Queries the information about an SAE namespace. For more information, see Use Terraform to manage SAE namespaces.

    alicloud_sae_application

    Queries the information about an SAE application. For more information, see Use Terraform to manage SAE applications.

    alicloud_sae_application_scaling_rule

    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.

    alicloud_sae_config_map

    Queries the information about an SAE ConfigMap.

    alicloud_sae_grey_tag_route

    Queries the information about a canary release rule of SAE.

    alicloud_sae_ingress

    Queries the information about an Ingress instance of SAE.

    alicloud_sae_load_balancer_internet

    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.

    alicloud_sae_load_balancer_intranet

    Queries the information about an internal-facing SLB instance of SAE.

    Table 2. Data sources

    Resource type

    Description

    alicloud_sae_service

    Activates SAE.

    alicloud_sae_namespaces

    Lists SAE namespaces.

    alicloud_sae_applications

    Lists SAE applications.

    alicloud_sae_application_scaling_rules

    Lists the auto scaling policies of SAE.

    alicloud_sae_config_maps

    Lists SAE ConfigMaps.

    alicloud_sae_grey_tag_routes

    Lists the canary release rules of SAE.

    alicloud_sae_ingresses

    Lists the Ingress instances of SAE.

    alicloud_sae_instance_specifications

    Lists the instance types of SAE.