模板名稱
ACS-TAG-ExtendEcsInstanceTagsByInputParams Ecs執行個體相關資源(Disk、Image、Snapshot、EIP、ENI)繼承執行個體的標籤
模板描述
Ecs執行個體相關資源(Disk、Image、Snapshot、EIP、ENI)繼承執行個體的標籤
模板類型
自動化
所有者
Alibaba Cloud
輸入參數
參數名稱 | 描述 | 類型 | 是否必填 | 預設值 | 約束 |
targets | 目標執行個體 | Json | 是 | ||
tagKeys | 所需繼承的標籤鍵列表 | List | 是 | ||
resourceTypes | 繼承標籤的資源類型列表 | List | 是 | ||
regionId | 地區ID | String | 否 | {{ ACS::RegionId }} | |
isUpdate | 是否覆蓋標籤值 | Boolean | 否 | False | |
rateControl | 任務執行的並發比率 | Json | 否 | {'Mode': 'Concurrency', 'MaxErrors': 100, 'Concurrency': 50} | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | "" |
輸出參數
無
執行此模板需要的權限原則
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeDisks",
"ecs:DescribeImages",
"ecs:DescribeInstances",
"ecs:DescribeNetworkInterfaces",
"ecs:DescribeSnapshots",
"ecs:TagResources"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"vpc:ListTagResources",
"vpc:TagResources"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳情
ACS-TAG-ExtendEcsInstanceTagsByInputParams詳情
模板內容
FormatVersion: OOS-2019-06-01
Description:
en: Ecs instance related resources (Disk, Image, Snapshot, EIP, ENI) inherit the Tags of the Instance
zh-cn: Ecs執行個體相關資源(Disk、Image、Snapshot、EIP、ENI)繼承執行個體的標籤
name-en: ACS-TAG-ExtendEcsInstanceTagsByInputParams
name-zh-cn: Ecs執行個體相關資源(Disk、Image、Snapshot、EIP、ENI)繼承執行個體的標籤
Parameters:
regionId:
Label:
en: RegionId
zh-cn: 地區ID
Type: String
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Label:
en: TargetInstance
zh-cn: 目標執行個體
Type: Json
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: ALIYUN::ECS::Instance
RegionId: regionId
tagKeys:
Label:
en: TagKeys
zh-cn: 所需繼承的標籤鍵列表
Type: List
resourceTypes:
Label:
en: ResourceTypes
zh-cn: 繼承標籤的資源類型列表
Type: List
AllowedValues:
- disk
- snapshot
- eni
- eip
- image
isUpdate:
Label:
en: IsUpdate
zh-cn: 是否覆蓋標籤值
Description:
en: Whether to overwrite the tag value if the tag key is the same
zh-cn: 如果標籤鍵相同,是否覆蓋標籤值
Type: Boolean
Default: false
rateControl:
Label:
en: RateControl
zh-cn: 任務執行的並發比率
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 100
Concurrency: 50
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstanceTagResources
Description:
en: Query the ECS instances
zh-cn: 擷取ECS執行個體以及標籤資訊
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: Disk Extend Tags
zh-cn: 磁碟是否繼承的標籤
Properties:
DefaultTask: isTagSnapshot
Choices:
- When:
Fn::Equals:
- true
- Fn::Jq:
- First
- contains(["disk"])
- '{{resourceTypes}}'
NextTask: tagDisk
- Name: tagDisk
Action: ACS::Template
Description:
en: Update disk tags by ecs instance tags
zh-cn: 通過雲端服務器標籤同步更新磁碟標籤
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: Snapshot Extend Tags
zh-cn: 快照是否繼承標籤
Properties:
DefaultTask: isTagENI
Choices:
- When:
Fn::Equals:
- true
- Fn::Jq:
- First
- contains(["snapshot"])
- '{{resourceTypes}}'
NextTask: tagSnapshot
- Name: tagSnapshot
Action: ACS::Template
Description:
en: Update snapshot tags by ecs instance tags
zh-cn: 通過雲端服務器標籤同步更新快照標籤
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: ENI Extend Tags
zh-cn: ENI 是否繼承標籤
Properties:
DefaultTask: isTagEIP
Choices:
- When:
Fn::Equals:
- true
- Fn::Jq:
- First
- contains(["eni"])
- '{{resourceTypes}}'
NextTask: tagENI
- Name: tagENI
Action: ACS::Template
Description:
en: Update eni tags by ecs instance tags
zh-cn: 通過雲端服務器標籤同步更新eni標籤
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: Choose next task by resource type
zh-cn: 根據資源類型選擇下一個任務
Properties:
DefaultTask: isTagImage
Choices:
- When:
Fn::Equals:
- true
- Fn::Jq:
- First
- contains(["eni"])
- '{{resourceTypes}}'
NextTask: tagEIP
- Name: tagEIP
Action: ACS::Template
Description:
en: Update eip tags By ecs instance tags
zh-cn: 通過雲端服務器標籤同步更新EIP標籤
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: Choose next task by resource type
zh-cn: 根據資源類型選擇下一個任務
Properties:
DefaultTask: ACS::END
Choices:
- When:
Fn::Equals:
- true
- Fn::Jq:
- First
- contains(["image"])
- '{{resourceTypes}}'
NextTask: tagImage
- Name: tagImage
Action: ACS::Template
Description:
en: Update custom image tags By ecs instance tags
zh-cn: 通過雲端服務器標籤同步更新Image標籤(只包括自訂鏡像)
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