All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ROS::ResourceCleaner

Last Updated:Jun 16, 2026

ALIYUN::ROS::ResourceCleaner creates a resource cleaner that scans for and cleans up resources.

Supported resource types

Note

ROS continually adds support for more resource types. You can call the GetFeatureDetails operation to obtain the list of supported resource types.

Alibaba Cloud service

Resource type

ACM

ACM:Namespace

ACTIONTRAIL

ACTIONTRAIL:Trail

ALB

  • ALB:Acl

  • ALB:HealthCheckTemplate

  • ALB:LoadBalancer

  • ALB:SecurityPolicy

  • ALB:ServerGroup

ApiGateway

  • ApiGateway:App

  • ApiGateway:Group

  • ApiGateway:Instance

  • ApiGateway:LogConfig

  • ApiGateway:Plugin

  • ApiGateway:Signature

  • ApiGateway:TrafficControl

ARMS

  • ARMS:AlertContact

  • ARMS:AlertContactGroup

  • ARMS:RetcodeApp

ASM

ASM:ServiceMesh

CAS

CAS:Certificate

CDDC

CDDC:DedicatedHostGroup

CDN

CDN:Domain

ClickHouse

ClickHouse:DBCluster

CloudPhone

CloudPhone:InstanceGroup

CMS

  • CMS:Contact

  • CMS:ContactGroup

  • CMS:MetricRuleTemplate

  • CMS:MonitorGroup

  • CMS:SiteMonitor

CS

CS:Cluster

CR

CR:Instance

DATAHUB

DATAHUB:Project

DCDN

DCDN:Domain

DFS

  • DFS:AccessGroup

  • DFS:FileSystem

DirectMail

  • DirectMail:Domain

  • DirectMail:Ipfilter

DNS

  • DNS:Domain

  • DNS:DomainGroup

DRDS

DRDS:DrdsInstance

ECI

  • ECI:ContainerGroup

  • ECI:ImageCache

ECS

  • ECS:AutoProvisioningGroup

  • ECS:AutoSnapshotPolicy

  • ECS:Command

  • ECS:CustomImage

  • ECS:DedicatedHost

  • ECS:DeploymentSet

  • ECS:Disk

  • ECS:HpcCluster

  • ECS:Instance

  • ECS:LaunchTemplate

  • ECS:NetworkInterface

  • ECS:PrefixList

  • ECS:SSHKeyPair

  • ECS:SecurityGroup

  • ECS:Snapshot

VPC

  • VPC:AnycastEIP

  • VPC:CommonBandwidthPackage

  • VPC:DhcpOptionsSet

  • VPC:EIP

  • VPC:EipSegment

  • VPC:FlowLog

  • VPC:HaVip

  • VPC:Ipv6Gateway

  • VPC:NatGateway

  • VPC:NetworkAcl

  • VPC:RouteTable

  • VPC:VPC

  • VPC:VSwitch

RAM

  • RAM:Group

  • RAM:ManagedPolicy

  • RAM:Role

  • RAM:SAMLProvider

  • RAM:User

RDS

RDS:DBInstance

ROS

ROS:Template

SLB

  • SLB:AccessControl

  • SLB:Certificate

  • SLB:LoadBalancer

ENS

ENS:Instance

ESS

  • ESS:AlarmTask

  • ESS:ScalingGroup

  • ESS:ScheduledTask

ECI

  • ECI:ContainerGroup

  • ECI:ImageCache

FNF

FNF:Flow

GPDB

GPDB:DBInstance

KMS

  • KMS:Key

  • KMS:Secret

KAFKA

KAFKA:Instance

MONGODB

MONGODB:Instance

Memcache

Memcache:Instance

MSE

  • MSE:Cluster

  • MSE:Gateway

MNS

  • MNS:Topic

  • MNS:Queue

REDIS

REDIS:Instance

SLS

SLS:Project

FC

FC:Service

NAS

  • NAS:AccessGroup

  • NAS:FileSystem

NLB

  • NLB:LoadBalancer

  • NLB:ServerGroup

OTS

OTS:Instance

OSS

OSS:Bucket

OOS

  • OOS:Execution

  • OOS:Template

  • OOS:PatchBaseline

  • OOS:Parameter

  • OOS:SecretParameter

POLARDB

POLARDB:DBCluster

PrivateLink

  • PrivateLink:VpcEndpoint

  • PrivateLink:VpcEndpointService

DRDS

DRDS:DrdsInstance

ROCKETMQ

ROCKETMQ:Instance

ADB

ADB:DBCluster

EDAS

  • EDAS:Application

  • EDAS:Cluster

EMR

EMR:Cluster

ElasticSearch

ElasticSearch:Instance

HBR

HBR:DBVault

PVTZ

PVTZ:Zone

SAE

  • SAE:Application

  • SAE:Namespace

SAG

  • SAG:ACL

  • SAG:Qos

TSDB

TSDB:HiTSDBInstance

WAF

WAF:Domain

Syntax

{
  "Type": "ALIYUN::ROS::ResourceCleaner",
  "Properties": {
    "Action": String,
    "ResourceFilters": List,
    "Resources": List,
    "Mode": String,
    "FailureOption": String,
    "CleanUpRetryCount": Integer,
    "CleanUpTimeout": Number,
    "ExcludedResources": List,
    "CleanUpAlgorithm": String,
    "ResourceTypeOrder": List,
    "DisabledSideEffects": List
  }
}

Properties

Property Name

Type

Required

Update allowed

Description

Constraints

Action

String

Yes

Yes

The action that the resource cleaner performs.

Valid values:

  • Scan: Scans for resources to clean up.

  • CleanUp: Cleans up the scanned resources. A scan must be performed first. This value can only be specified during an update, not when creating a resource cleaner.

  • Scan+CleanUp: Scans for resources and then cleans them up.

  • ScanWhenCreatingAndUpdating+CleanUpWhenDeleting: Scans for resources when the resource cleaner is created or updated, and cleans up resources when the resource cleaner is deleted.

ResourceFilters

List

No

Yes

The resource filters used by the resource cleaner to scan for resources that need to be cleaned up.

The list can contain up to 100 filters.

You can specify either ResourceFilters or Resources, but not both.

If the list of resource filters is changed during an update, the resource cleaner rescans the resources. If the Action is set to CleanUp, the operation fails.

Filters have two effects: Allow and Deny. They work as follows (a smaller number indicates a higher priority):

  1. Resources that match any Deny filter are not cleaned up.

  2. Only resources that match at least one Allow filter are cleaned up.

For more information, see ResourceFilters properties.

Resources

List

No

Yes

The resources to clean up.

The list can contain 1 to 1,000 resources.

You can specify either ResourceFilters or Resources, but not both.

For more information, see Resources properties.

Mode

String

No

Yes

The execution mode of the resource cleaner.

Valid values:

  • Strict: Any failure in resource scanning or cleanup causes the resource cleaner to fail.

  • Loose (default): Most scanning and cleanup failures are tolerated. Scanning failures are recorded in ScanErrors and ResourceDetails. Cleanup failures are recorded in ResourceDetails.

FailureOption

String

No

Yes

The behavior for dependent resources when a resource cleanup fails.

Valid values:

  • Normal (default): A resource cleanup failure does not affect dependent resources.

  • Fast: A resource cleanup failure causes dependent resources to fail.

Note

The dependency is a deletion dependency, not a creation dependency.

CleanUpRetryCount

Integer

No

Yes

The maximum number of cleanup retries.

Valid values: 1 to 6.

The default value is 1, which means no retries.

A retry is triggered if one of the following conditions is met:

  • A resource cleanup fails.

  • The cleanup times out.

CleanUpTimeout

Number

No

Yes

The timeout period for resource cleanup.

Valid values: 60 to 14400.

Unit: seconds.

Default value: 3600.

ExcludedResources

List

No

Yes

The resources to exclude from cleanup.

The list can contain 1 to 1,000 resources.

Each item can exclude only one resource. If an item is ambiguous and points to multiple resources, the operation fails. Specify more fields to remove ambiguity.

For more information, see ExcludedResources properties.

CleanUpAlgorithm

String

No

Yes

The resource cleanup algorithm.

Valid values:

  • ResourceDependency (default): Resources are cleaned up based on their dependencies.

  • ResourceTypeOrder: Resources are cleaned up in the order of resource types. You can use the ResourceTypeOrder property to specify the order. If you do not specify this property, the system's default order is used. The default order includes all supported resource types.

ResourceTypeOrder

List

No

Yes

The cleanup order of resource types.

The number of items in the list must be in the range of 1 to 1,000.

This parameter takes effect only when CleanUpAlgorithm is set to ResourceTypeOrder.

Resources of types not specified in the list are not scanned or cleaned up.

For information about valid resource types, see Supported resource types.

DisabledSideEffects

List

No

Yes

The side effects to disable during cleanup.

The list can contain 1 to 50 items.

Each item can consist of letters, digits, and wildcard characters. The length of each item is 1 to 100 characters.

Only the * and ? wildcard characters are supported.

Cleaning up some types of resources can have side effects. You can call the GetFeatureDetails operation to query them.

ResourceFilters syntax

"ResourceFilters": [
  {
    "IncludeDeletionProtection": Boolean,
    "ResourceTypePatterns": List,
    "ResourceIds": List,
    "RegionIds": List,
    "ResourceGroupIds": List,
    "Effect": String,
    "ResourceNamePatterns": List,
    "Tags": List
  }
]

ResourceFilters properties

Property name

Type

Required

Update allowed

Description

Constraints

IncludeDeletionProtection

Boolean

No

Yes

Specifies whether to include resources that have deletion protection enabled.

Valid values:

  • false: Resources with deletion protection enabled do not pass this filter.

  • true (default): Resources with deletion protection enabled pass this filter.

ResourceTypePatterns

List

No

Yes

A list of patterns for resource types to filter. For information about resource types, see Supported resource types.

The list can contain 1 to 100 patterns.

A resource passes this filter if its type matches any pattern in the list.

Only the * and ? wildcard characters are supported.

Each pattern in the list must be in the Service:Type format and be 3 to 100 characters in length. Service can consist of letters and wildcard characters. Type can consist of letters, digits, and wildcard characters.

ResourceIds

List

No

Yes

A list of resource IDs to filter.

The list can contain 1 to 100 IDs.

A resource passes this filter if its ID matches any ID in the list.

A list item can be 1 to 256 characters long.

RegionIds

List

No

Yes

A list of regions to filter.

The length of the list must be from 1 to 100.

A resource passes this filter if its region matches any region in the list.

A list item must be 1 to 64 characters in length.

ResourceGroupIds

List

No

Yes

A list of resource groups to filter.

The length of the list ranges from 1 to 100.

A resource passes this filter if it belongs to any resource group in the list.

The length of a list item must be from 1 to 256 characters.

Effect

String

No

Yes

The filter effect.

Valid values:

  • Deny: Resources that pass all filter conditions are excluded from cleanup.

  • Allow: Resources that match all filter conditions are cleaned up.

    Note

    If a resource passes this filter but also passes a Deny filter, it is still not cleaned up.

ResourceNamePatterns

List

No

Yes

The resource name patterns to filter by.

The list can contain 1 to 100 patterns.

A resource passes this filter if its name matches any pattern in the list.

Only the * and ? wildcard characters are supported.

Resource names only support letters, numbers, Chinese characters, spaces, _, -, and fuzzy match characters.

The length of a list item can range from 1 to 100.

Tags

List

No

Yes

The tags to filter by. Both custom tags and system tags are supported.

The list must contain 1 to 100 items.

Matching rules:

  • If you specify both a tag key and a tag value, resources whose tag key and tag value match are filtered.

    Note
    1. If a tag key has multiple values in the filter, a resource matches if its tag value is any of those values.

    2. If a filter specifies only a tag key, a resource matches if it has that tag key.

  • A resource passes the tag filter only if it matches the filter conditions for all specified tag keys.

For more information, see Tags properties.

Tags syntax

"Tags": [
  {
    "Value": String,
    "Key": String
  }
]

Tags properties

Property name

Type

Required

Update allowed

Description

Constraints

Value

String

No

Yes

The tag value.

Length: 0 to 256 characters.

Note

Omitting this value is different from specifying an empty string.

Key

String

Yes

Yes

The tag key.

Length: 1 to 256 characters.

Resources syntax

"Resources": [
  {
    "ResourceId": String,
    "ResourceType": String,
    "RegionId": String
  }
]

Resources properties

Property Name

Type

Required

Update allowed

Description

Constraints

ResourceId

String

Yes

Yes

The ID of the resource to be cleaned up.

Length: 1 to 256 characters.

ResourceType

String

Yes

Yes

The type of the resource to be cleaned up.

For more information, see Supported resource types.

RegionId

String

Yes

Yes

The region ID of the resource to be cleaned up.

Length: 1 to 64 characters.

ExcludedResources syntax

"ExcludedResources": [
  {
    "ResourceId": String,
    "ResourceType": String,
    "RegionId": String
  }
]

ExcludedResources properties

Property name

Type

Required

Update allowed

Description

Constraints

ResourceId

String

Yes

Yes

The ID of the resource to be excluded.

Length: 1 to 256 characters.

ResourceType

String

No

Yes

The type of the resource to be excluded.

For more information, see Supported resource types.

RegionId

String

No

Yes

The region ID of the resource to be excluded.

Length: 1 to 64 characters.

Return values

Fn::GetAtt

  • ResourceDetails: The details of the resources to clean up. The value is a list of dictionaries with the following fields:

    Field

    Type

    Description

    ResourceType

    String

    The resource type.

    RegionId

    String

    The region ID of the resource.

    ResourceId

    String

    The resource ID.

    ResourceName

    String

    The resource name.

    CleanupType

    String

    The cleanup type of the resource. Valid values:

    • Normal: The resource can be deleted normally.

    • DeleteWithInstance: The resource is deleted along with the resource to which it belongs. If the resource to which it belongs is filtered or excluded, deletion may fail. See CleanupTypeReasons for details.

    • UnableToDelete: The resource cannot be deleted. See CleanupTypeReasons for details.

    CleanupTypeReasons

    List

    A list of reasons for the resource cleanup type.

    ResourceStatus

    String

    The status of the resource. Valid values:

    • Deleting: The resource is being deleted.

    • Failure: The resource failed to be deleted.

    • Success: The resource was deleted.

    • Skipped: The resource deletion was skipped.

    • Pending: The resource is pending deletion.

    ResourceStatusReason

    String

    The reason for the resource status.

    Dependencies

    List

    The deletion dependencies of the resource. The value is a list of dictionaries with the following fields:

    • ResourceType: The resource type of the dependent resource.

    • RegionId: The region ID of the dependent resource.

    • ResourceId: The ID of the dependent resource.

  • ResourcePartialDetails: A simplified version of ResourceDetails that includes only the ResourceType, RegionId, ResourceId, ResourceName, ResourceStatus, and ResourceStatusReason fields.

  • NoCleanupResourceDetails: The details of resources that are scanned but not cleaned up. The format is the same as ResourceDetails.

  • NoCleanupResourcePartialDetails: A simplified version of NoCleanupResourceDetails that includes only the ResourceType, RegionId, ResourceId, ResourceName, ResourceStatus, and ResourceStatusReason fields.

  • ResourceSummary: A summary of the resources to clean up. The value is a list of dictionaries with the following fields:

    Field

    Type

    Description

    ResourceType

    String

    The resource type.

    DeletingCount

    Integer

    The number of resources being deleted.

    SuccessCount

    Integer

    The number of deleted resources.

    FailureCount

    Integer

    The number of resources that failed to be deleted.

    SkippedCount

    Integer

    The number of resources whose deletion was skipped.

    PendingCount

    Integer

    The number of resources pending deletion.

    OtherCount

    Integer

    The number of resources in other states.

    TotalCount

    Integer

    The total number of resources.

  • ScanErrors: The errors that occurred during scanning. This parameter is returned only when Mode is set to Loose. The value is a list of dictionaries with the following fields:

    Field

    Type

    Description

    ResourceType

    String

    The resource type.

    RegionId

    String

    The region ID.

    ErrorMessage

    String

    The error message for the scan of the specified region and resource type.

  • CleanResult: The overall cleanup result. Valid values:

    • Success: All resources were cleaned up.

    • ResourceFailure: The cleanup of some resources failed.

    • Timeout: The cleanup timed out.

    • CheckFailure: The cleanup precheck failed.

    • UnknownFailure: An unknown error occurred.

    • UserCancelled: The operation was canceled by the user.

    • None: No cleanup was triggered.

Examples

  • YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters: {}
    Resources:
      ResourceCleaner:
        Type: ALIYUN::ROS::ResourceCleaner
        Properties:
          FailureOption: Normal
          Action: Scan
          ResourceFilters:
            - ResourceIds:
                - i-bp1h09ipy0atb4kq****
          CleanUpRetryCount: 1
          CleanUpTimeout: 3600
          ExcludedResources:
            - ResourceId: i-bp1h09ipy0atb4kq****
              ResourceType: ECS:Instance
    Outputs: {}
  • JSON format

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
      },
      "Resources": {
        "ResourceCleaner": {
          "Type": "ALIYUN::ROS::ResourceCleaner",
          "Properties": {
            "FailureOption": "Normal",
            "Action": "Scan",
            "ResourceFilters": [
              {
                "ResourceIds": [
                  "i-bp1h09ipy0atb4kq****"
                ]
              }
            ],
            "CleanUpRetryCount": 1,
            "CleanUpTimeout": 3600,
            "ExcludedResources": [
              {
                "ResourceId": "i-bp1h09ipy0atb4kq****",
                "ResourceType": "ECS:Instance"
              }
            ]
          }
        }
      },
      "Outputs": {
      }
    }