All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-InheritDiskTagToSnapshot

Last Updated:Nov 25, 2024

Template name

ACS-ECS-InheritDiskTagToSnapshot

Execute Now

Template description

Inherits all disk tags in a region to snapshots.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

tagKeys

The tag keys to be inherited.

List

Yes

OOSAssumeRole

None

String

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

isUpdate

Specifies whether to overwrite the values of tags that have the same keys as the tags to be inherited.

Boolean

No

False

rateControl

The rate control settings.

Json

No

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

Output parameters

None

Permission policy that is required to execute the template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeDisks",
                "ecs:DescribeSnapshots",
                "ecs:TagResources"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

References

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

Template content

FormatVersion: OOS-2019-06-01
Description:
  name-en: ACS-ECS-InheritDiskTagToSnapshot 
  name-zh-cn: the description in Chinese
  en: Inherit all disk tags to snapshots
  zh-cn: the description in Chinese
Parameters:
  regionId:
    Type: String
    Description:
      en: The id of region
      zh-cn: the description in Chinese
    Label:
      en: Region
      zh-cn: the description in Chinese
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  tagKeys:
    Type: List
    Description:
      en: The list of tag key
      zh-cn: the description in Chinese
    Label:
      en: TagKeys
      zh-cn: the description in Chinese
  isUpdate:
    Type: Boolean
    Label:
      en: IsUpdate
      zh-cn: the description in Chinese
    Description:
      en: Whether to overwrite the tag value if the tag key is the same
      zh-cn: the description in Chinese
    Default: false
  rateControl:
    Label:
      en: RateControl
      zh-cn: the description in Chinese
    Description: 
      en: Concurrency rate of task execution
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 100
      Concurrency: 10
  OOSAssumeRole:
    Description:
      name-en: The RAM role to be assumed by OOS.
      name-zh-cn: the description in Chinese 
    Type: String
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getDisks
    Action: ACS::ExecuteAPI
    Description: 
      en: Query the disk information
      zh-cn: the description in Chinese
    Properties:
      Service: ECS
      API: DescribeDisks
      Parameters:
        RegionId: '{{ regionId }}'
    Outputs:
      disks:
        Type: List
        ValueSelector: .Disks.Disk[].DiskId
  - Name: tagSnapshot
    Action: ACS::ECS::InheritDiskTagToSnapshot
    Description: 
      en: Inherit the specified disk tags to snapshots
      zh-cn: the description in Chinese
    Properties:
      regionId: '{{ regionId }}'
      diskId: '{{ACS::TaskLoopItem}}'
      tagKeys: '{{tagKeys}}'
      isUpdate: '{{isUpdate}}'
      rateControl: '{{rateControl}}'
    Loop:
      RateControl: '{{rateControl}}'
      Items: '{{getDisks.disks}}'
      Outputs:
        tagResult:
          AggregateType: Fn::ListJoin
          AggregateField: reqResult