All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-BulkyTagInstances

Last Updated:Dec 22, 2025

Template name

ACS-ECS-BulkyTagInstances: Batch-attaches tags to ECS instances

Execute Now

Template description

Adds tags to multiple Elastic Compute Service (ECS) instances at a time.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

targets

Target instance

Json

Yes

tags

The tags to be added to the ECS instances.

Json

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

rateControl

Task Execution Concurrency Ratio

Json

No

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS).

String

No

""

Output parameters

None

Permission policy that is required to execute the template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:TagResources"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:GetApplicationGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Details

For more information, see ACS-ECS-BulkyTagInstances.yml at GitHub.

Template content

FormatVersion: OOS-2019-06-01
Description:
  name-en: ACS-ECS-BulkyTagInstances
  name-zh-cn: Batch attach tags to ECS instances
  en: Bulky tag ECS instances
  zh-cn: Batch attach tags to ECS instances
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: Region ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Type: Json
    Label:
      en: TargetInstance
      zh-cn: Target Instance
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  tags:
    Label:
      en: Tags
      zh-cn: Tags to attach to the ECS instances
    Type: Json
    AssociationProperty: Tags
  rateControl:
    Label:
      en: RateControl
      zh-cn: Concurrency rate for task execution
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: The RAM role assumed by OOS
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances
      zh-cn: Views the ECS instances
    Action: 'ACS::SelectTargets'
    Properties:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: 'Instances.Instance[].InstanceId'
  - Name: tagResources
    Action: 'ACS::ExecuteApi'
    Description:
      en: Creates and attaches tag to ECS instance
      zh-cn: Creates and attaches tag to ECS instance
    Properties:
      Service: ECS
      API: TagResources
      Parameters:
        RegionId: '{{ regionId }}'
        ResourceIds:
          - '{{ ACS::TaskLoopItem }}'
        ResourceType: Instance
        Tags: '{{ tags }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - tags
        Label:
          default:
            zh-cn: Configure Parameters
            en: Configure Parameters
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: Select Ecs Instances
            en: Select Ecs Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Control Options
            en: Control Options