Help Center/ Cloud Container Engine/ Best Practices/ Terraform/ Deleting a CCE Cluster Using Terraform
Updated on 2026-08-20 GMT+08:00

Deleting a CCE Cluster Using Terraform

When you delete a CCE cluster using Terraform, the storage resources (EVS disks, object storage, SFS file storage, and SFS Turbo file storage) and LTS logs associated with the cluster will not be automatically deleted. Residual resources will be continuously billed. To clear these associated resources when deleting a cluster, you can modify the deletion policy parameters in the Terraform configuration.

This section describes how to add deletion policy parameters to the Terraform configuration of an existing CCE cluster so that associated resources are automatically cleared when the cluster is deleted.

Prerequisites

Procedure

Step 1: Modify the Cluster Configuration

  1. Go to the Terraform module directory of the CCE cluster, for example, terraform_cce_cluster.
    cd terraform_cce_cluster
  2. Open the cce_cluster.tf file that contains the CCE cluster resource configuration and add the deletion policy parameters to the huaweicloud_cce_cluster resource block.
    resource "huaweicloud_cce_cluster" "test" {
      # Add the following parameters to the end of the resource block:
      ...
    
      delete_evs         = true
      delete_obs         = true
      delete_sfs         = true
      delete_efs         = true
      # The delete_all parameter conflicts with the preceding four fields and cannot be configured together.
      # delete_all       = true
    
      lts_reclaim_policy = "Delete_Log_Group"
    }

    The involved parameters are described in the table below.

    Parameter

    Description

    delete_evs

    Whether to delete the EVS disk when deleting the cluster. The value true indicates the EVS disk will be deleted.

    delete_obs

    Whether to delete the object storage when deleting the cluster. The value true indicates the object storage will be deleted.

    delete_sfs

    Whether to delete the file storage when deleting the cluster. The value true indicates the SFS file storage will be deleted.

    delete_efs

    Whether to delete the SFS Turbo file storage when deleting the cluster. The value true indicates the SFS Turbo file storage will be deleted.

    delete_all

    Whether to delete all associated storage resources when deleting the cluster. This parameter conflicts with the preceding four parameters and cannot be configured together with them.

    lts_reclaim_policy

    LTS log deletion policy when deleting a cluster. Delete_Log_Group: Delete the log group and its log streams. Delete_Master_Log_Stream: Delete the primary log stream. Retain: Retain the log streams and log group.

    delete_all conflicts with delete_evs, delete_obs, delete_sfs, and delete_efs. You can configure either delete_all or the later four parameters.

Step 2: Apply the Modified Configuration

Run the following command to apply the modified configuration to the cluster:

terraform apply

Terraform will ask for your confirmation. Enter yes to confirm the execution. After the command is executed, "1 changed" is displayed, indicating that the modified configuration has taken effect.

Step 3: Delete the Cluster

Run the command below to delete the CCE cluster. The storage resources and LTS logs associated with the cluster will be processed based on the deletion policy configured in step 1.

This operation will permanently delete the CCE cluster and its associated storage resources. Ensure that you have backed up the data before performing this operation.

terraform destroy
Terraform will ask for your confirmation. Enter yes to confirm the execution.

Helpful Links