全部产品
Search
文档中心

CloudOps Orchestration Service:ACS-TAG-ExtendEcsInstanceTagsByInputParams

更新时间:Dec 21, 2025

Nama template

Aksi ACS-TAG-ExtendEcsInstanceTagsByInputParams menyebabkan sumber daya yang terkait dengan instance ECS—seperti disk, image, snapshot, EIP, dan ENI—mewarisi tag dari instance tersebut.

Jalankan Sekarang

Deskripsi template

Menerapkan tag dari instance Elastic Compute Service (ECS) ke sumber daya terkait seperti disk, gambar, snapshot, elastic IP addresses (EIPs), dan elastic network interfaces (ENIs).

Tipe template

Otomatis

Pemilik

Alibaba Cloud

Parameter input

Parameter

Deskripsi

Tipe

Diperlukan

Nilai default

Batasan

targets

Instance tujuan.

Json

Ya

tagKeys

Kunci tag yang akan diterapkan.

Daftar

Ya

resourceTypes

Tipe sumber daya tempat tag diterapkan.

Daftar

Ya

regionId

ID wilayah.

String

Tidak

{{ ACS::RegionId }}

isUpdate

Menentukan apakah akan menimpa nilai tag.

Boolean

Tidak

False

rateControl

Konkurensi eksekusi tugas

Json

Tidak

{'Mode': 'Concurrency', 'MaxErrors': 100, 'Concurrency': 50}

OOSAssumeRole

Peran Resource Access Management (RAM) yang diasumsikan oleh CloudOps Orchestration Service (OOS).

String

Tidak

""

Parameter output

Tidak ada

Kebijakan izin yang diperlukan untuk menjalankan template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeDisks",
                "ecs:DescribeImages",
                "ecs:DescribeInstances",
                "ecs:DescribeNetworkInterfaces",
                "ecs:DescribeSnapshots",
                "ecs:TagResources"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:GetApplicationGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "vpc:ListTagResources",
                "vpc:TagResources"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Detail

Untuk informasi lebih lanjut, lihat ACS-TAG-ExtendEcsInstanceTagsByInputParams.yml di GitHub.

Isi Template

FormatVersion: OOS-2019-06-01
Description:
  en: Applies tags from an ECS instance to its related resources (disks, images, snapshots, EIPs, and ENIs).
  zh-cn: Applies tags from an ECS instance to its related resources (disks, images, snapshots, EIPs, and ENIs).
  name-en: ACS-TAG-ExtendEcsInstanceTagsByInputParams
  name-zh-cn: Applies tags from an ECS instance to its related resources (disks, images, snapshots, EIPs, and ENIs).
  categories:
    - tag_manage
Parameters:
  regionId:
    Label:
      en: Region
      zh-cn: Region
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Label:
      en: TargetInstance
      zh-cn: Target Instances
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: regionId
  tagKeys:
    Label:
      en: TagKeys
      zh-cn: Tag Keys to Inherit
    Type: List
  resourceTypes:
    Label:
      en: ResourceTypes
      zh-cn: Resource Types to Inherit Tags
    Type: List
    AllowedValues:
      - disk
      - snapshot
      - eni
      - eip
      - image
  isUpdate:
    Label:
      en: IsUpdate
      zh-cn: Overwrite Tag Value
    Description:
      en: Whether to overwrite the tag value if the tag key is the same
      zh-cn: Whether to overwrite the tag value if the tag key is the same
    Type: Boolean
    Default: false
  rateControl:
    Label:
      en: RateControl
      zh-cn: Task Concurrency Rate
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 100
      Concurrency: 50
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS RAM Role
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstanceTagResources
    Description:
      en: Queries the ECS instances and their tag information.
      zh-cn: Queries the ECS instances and their tag information.
    Action: ACS::SelectTargets
    Properties:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      desData:
        Type: List
        ValueSelector: '.Instances.Instance[] | {"Tags": .Tags.Tag | map(select( .TagKey | test("^(?!acs).*"))) | map(select(.TagKey as $tagKey | {{tagKeys}} | index($tagKey) >=0)) , "InstanceId": .InstanceId}?'
  - Name: isTagDisk
    Action: ACS::Choice
    Description:
      en: Checks whether to extend tags to disks.
      zh-cn: Checks whether to extend tags to disks.
    Properties:
      DefaultTask: isTagSnapshot
      Choices:
        - When:
            Fn::Equals:
              - true
              - Fn::Jq:
                  - First
                  - contains(["disk"])
                  - '{{resourceTypes}}'
          NextTask: tagDisk
  - Name: tagDisk
    Action: ACS::Template
    Description:
      en: Updates disk tags based on the ECS instance tags.
      zh-cn: Updates disk tags based on the ECS instance tags.
    OnSuccess: isTagSnapshot
    Properties:
      TemplateName: ACS::ECS::UpdateDiskTagsByEcsInstanceTags
      Parameters:
        regionId: '{{ regionId }}'
        instanceId:
          Fn::Jq:
            - First
            - .InstanceId
            - '{{ACS::TaskLoopItem}}'
        tagKeys: '{{tagKeys}}'
        isUpdate: '{{isUpdate}}'
    Loop:
      RateControl: '{{rateControl}}'
      Items: '{{getInstanceTagResources.desData}}'
      Outputs:
        tagResult:
          AggregateType: Fn::ListJoin
          AggregateField: reqResult
  - Name: isTagSnapshot
    Action: ACS::Choice
    Description:
      en: Checks whether to extend tags to snapshots.
      zh-cn: Checks whether to extend tags to snapshots.
    Properties:
      DefaultTask: isTagENI
      Choices:
        - When:
            Fn::Equals:
              - true
              - Fn::Jq:
                  - First
                  - contains(["snapshot"])
                  - '{{resourceTypes}}'
          NextTask: tagSnapshot
  - Name: tagSnapshot
    Action: ACS::Template
    Description:
      en: Updates snapshot tags based on the ECS instance tags.
      zh-cn: Updates snapshot tags based on the ECS instance tags.
    OnSuccess: isTagENI
    Properties:
      TemplateName: ACS::ECS::UpdateSnapshotTagsByEcsInstanceTags
      Parameters:
        regionId: '{{regionId}}'
        instanceId:
          Fn::Jq:
            - First
            - .InstanceId
            - '{{ACS::TaskLoopItem}}'
        tagKeys: '{{tagKeys}}'
        isUpdate: '{{isUpdate}}'
    Loop:
      RateControl: '{{rateControl}}'
      Items: '{{getInstanceTagResources.desData}}'
      Outputs:
        tagResult:
          AggregateType: Fn::ListJoin
          AggregateField: reqResult
  - Name: isTagENI
    Action: ACS::Choice
    Description:
      en: Checks whether to extend tags to ENIs.
      zh-cn: Checks whether to extend tags to ENIs.
    Properties:
      DefaultTask: isTagEIP
      Choices:
        - When:
            Fn::Equals:
              - true
              - Fn::Jq:
                  - First
                  - contains(["eni"])
                  - '{{resourceTypes}}'
          NextTask: tagENI
  - Name: tagENI
    Action: ACS::Template
    Description:
      en: Updates ENI tags based on the ECS instance tags.
      zh-cn: Updates ENI tags based on the ECS instance tags.
    OnSuccess: isTagEIP
    Properties:
      TemplateName: ACS::ECS::UpdateEniTagsByEcsInstanceTags
      Parameters:
        regionId: '{{ regionId }}'
        instanceId:
          Fn::Jq:
            - First
            - .InstanceId
            - '{{ACS::TaskLoopItem}}'
        tagKeys: '{{tagKeys}}'
        isUpdate: '{{isUpdate}}'
    Loop:
      RateControl: '{{rateControl}}'
      Items: '{{getInstanceTagResources.desData}}'
      Outputs:
        tagResult:
          AggregateType: Fn::ListJoin
          AggregateField: reqResult
  - Name: isTagEIP
    Action: ACS::Choice
    Description:
      en: Chooses the next task based on the resource type.
      zh-cn: Chooses the next task based on the resource type.
    Properties:
      DefaultTask: isTagImage
      Choices:
        - When:
            Fn::Equals:
              - true
              - Fn::Jq:
                  - First
                  - contains(["eni"])
                  - '{{resourceTypes}}'
          NextTask: tagEIP
  - Name: tagEIP
    Action: ACS::Template
    Description:
      en: Updates EIP tags based on the ECS instance tags.
      zh-cn: Updates EIP tags based on the ECS instance tags.
    OnSuccess: isTagImage
    Properties:
      TemplateName: ACS::ECS::UpdateEipTagsByEcsInstanceTags
      Parameters:
        regionId: '{{ regionId }}'
        instanceId:
          Fn::Jq:
            - First
            - .InstanceId
            - '{{ACS::TaskLoopItem}}'
        tagKeys: '{{tagKeys}}'
        isUpdate: '{{isUpdate}}'
    Loop:
      RateControl: '{{rateControl}}'
      Items: '{{getInstanceTagResources.desData}}'
      Outputs:
        tagResult:
          AggregateType: Fn::ListJoin
          AggregateField: reqResult
  - Name: isTagImage
    Action: ACS::Choice
    Description:
      en: Chooses the next task based on the resource type.
      zh-cn: Chooses the next task based on the resource type.
    Properties:
      DefaultTask: ACS::END
      Choices:
        - When:
            Fn::Equals:
              - true
              - Fn::Jq:
                  - First
                  - contains(["image"])
                  - '{{resourceTypes}}'
          NextTask: tagImage
  - Name: tagImage
    Action: ACS::Template
    Description:
      en: Updates custom image tags based on the ECS instance tags.
      zh-cn: Updates custom image tags based on the ECS instance tags.
    OnSuccess: ACS::END
    Properties:
      TemplateName: ACS::ECS::UpdateCustomImageTagsByEcsInstanceTags
      Parameters:
        regionId: '{{ regionId }}'
        instanceId:
          Fn::Jq:
            - First
            - .InstanceId
            - '{{ACS::TaskLoopItem}}'
        tagKeys: '{{tagKeys}}'
        isUpdate: '{{isUpdate}}'
    Loop:
      RateControl: '{{rateControl}}'
      Items: '{{getInstanceTagResources.desData}}'
      Outputs:
        tagResult:
          AggregateType: Fn::ListJoin
          AggregateField: reqResult