All Products
Search
Document Center

Container Service for Kubernetes:Terraform overview

Last Updated:Mar 26, 2026

Terraform is an open-source infrastructure as code (IaC) tool for provisioning and managing cloud resources. The Alibaba Cloud Provider (terraform-provider-alicloud) lets you create, update, and delete ACK clusters and their associated resources through declarative configuration files.

Why use Terraform with ACK

Terraform extends what the ACK console and CLI offer on their own:

  • Unified workflow: Define your entire stack — VPC, node pools, RBAC permissions, and add-ons — in a single set of .tf files. If you already use Terraform for other Alibaba Cloud resources, ACK fits into the same workflow without additional tooling.

  • Full lifecycle management: Terraform tracks the state of every resource it creates. To update a node pool or delete a cluster, edit the configuration and run terraform apply — Terraform determines what changes to make without requiring you to call APIs directly.

  • Dependency graph: Terraform understands resource dependencies. For example, it will not attempt to create a node pool if the cluster fails to provision first.

  • Repeatable environments: Apply the same configuration to create identical development, staging, and production clusters, eliminating configuration drift between environments.

Key concepts

Terraform uses two types of objects to manage infrastructure:

TypeDescription
ResourceCreates and manages a new object (for example, an ACK managed cluster or a node pool).
Data sourceQueries existing resource information without creating anything (for example, listing available Kubernetes versions).

Terraform interacts with Alibaba Cloud through the following plug-ins:

Plug-in typeDescription
Terraform CLIThe command-line interface used to run Terraform commands.
Terraform providersPlug-ins that interface Terraform with cloud APIs. The alicloud provider is developed and maintained by Alibaba Cloud. See Alibaba Cloud Provider.
Resource Orchestration Service (ROS)Provides Terraform-based management through the ROS console, so you can use Terraform templates to deploy and manage resources without installing Terraform locally. See Create a Terraform stack.

Alibaba Cloud is the first cloud service provider in China to integrate Terraform with its services. The alicloud provider covers 35 Alibaba Cloud services — including computing, storage, networking, load balancing, CDN, middleware, access control, and database services — with 163 resources and 113 data sources. See Alibaba Cloud Provider.

ACK resources and data sources

The following resources and data sources are available for managing ACK through Terraform.

Resources

ResourceDescription
alicloud_cs_managed_kubernetesManages ACK managed clusters.
alicloud_cs_kubernetesManages ACK dedicated clusters.
alicloud_cs_serverless_kubernetesManages ACK Serverless clusters.
alicloud_cs_edge_kubernetesManages ACK edge clusters.
alicloud_cs_kubernetes_node_poolManages node pools.
alicloud_cs_kubernetes_permissionsManages Role-Based Access Control (RBAC) permissions.
alicloud_cs_kubernetes_addonManages cluster add-ons.

Data sources

Data sourceDescription
alicloud_ack_serviceActivates ACK.
alicloud_cs_managed_kubernetes_clustersLists all ACK managed clusters.
alicloud_cs_kubernetes_clustersLists all ACK dedicated clusters.
alicloud_cs_serverless_kubernetes_clustersLists all ACK Serverless clusters.
alicloud_cs_edge_kubernetes_clustersLists all ACK edge clusters.
alicloud_cs_kubernetes_node_poolsLists node pool information in the specified cluster.
alicloud_cs_kubernetes_permissionsLists all permissions of specified Resource Access Management (RAM) users.
alicloud_cs_kubernetes_versionLists available Kubernetes versions.
alicloud_cs_kubernetes_addonsLists available cluster add-ons.
alicloud_cs_kubernetes_addon_metadataLists metadata for cluster add-ons.

Generate Terraform configuration from the console

The ACK console can generate Terraform configuration snippets from your cluster settings, so you don't need to write configuration from scratch.

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click Cluster Templates.

  3. In the Select Cluster Template dialog box, find the target cluster type and click Create. On the Cluster Configurations step, configure the parameters.

  4. Click Generate API Request Parameters on the Confirm step.

  5. Click the Terraform tab to retrieve the configuration snippets for your cluster.

Copy the generated snippets into your .tf files as a starting point, then customize them as needed.

What's next