Nome do modelo
A ação ACS-TAG-ExtendEcsInstanceTagsByInputParams permite que recursos associados a uma instância ECS, como discos, imagens, snapshots, EIPs e ENIs, herdem as tags da instância.
Descrição do modelo
Aplica tags de instâncias do Elastic Compute Service (ECS) a recursos associados, como discos, imagens, snapshots, endereços IP elásticos (EIPs) e interfaces de rede elásticas (ENIs).
Tipo de modelo
Automatizado
Proprietário
Alibaba Cloud
Parâmetros de entrada
|
Parâmetro |
Descrição |
Tipo |
Obrigatório |
Valor padrão |
Limite |
|
targets |
Instâncias de destino. |
Json |
Sim |
||
|
tagKeys |
Chaves de tag a aplicar. |
List |
Sim |
||
|
resourceTypes |
Tipos de recursos que receberão as tags. |
List |
Sim |
||
|
regionId |
ID da região. |
String |
Não |
{{ ACS::RegionId }} |
|
|
isUpdate |
Indica se os valores das tags devem ser sobrescritos. |
Boolean |
Não |
False |
|
|
rateControl |
Concorrência de execução da tarefa. |
Json |
Não |
{'Mode': 'Concurrency', 'MaxErrors': 100, 'Concurrency': 50} |
|
|
OOSAssumeRole |
Função do Resource Access Management (RAM) assumida pelo CloudOps Orchestration Service (OOS). |
String |
Não |
"" |
Parâmetros de saída
Nenhum
Política de permissão necessária para executar o modelo
{
"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"
}
]
}
Detalhes
Para mais informações, consulte ACS-TAG-ExtendEcsInstanceTagsByInputParams.yml no GitHub.
Conteúdo do modelo
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