模板名称
ACS-ECS-CorrectSecurityGroupInstancesByTags 纠正安全组实例标签
模板描述
根据标签获取实例并把获取的到的实例加入到指定标签下的安全组中
模板类型
自动化
所有者
Alibaba Cloud
输入参数
参数名称 | 描述 | 类型 | 是否必填 | 默认值 | 约束 |
tags | 要添加的新ECS实例的标签 | Json | 是 | ||
regionId | 地域ID | String | 否 | {{ ACS::RegionId }} |
输出参数
无
执行此模板需要的权限策略
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeSecurityGroups",
"ecs:JoinSecurityGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
详情
ACS-ECS-CorrectSecurityGroupInstancesByTags详情
模板内容
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS-ECS-CorrectSecurityGroupInstancesByTags
name-zh-cn: 纠正安全组实例标签
en: Gets an instance from a label and adds the acquired instance to the security group under the specified label
zh-cn: 根据标签获取实例并把获取的到的实例加入到指定标签下的安全组中
Parameters:
regionId:
Label:
en: RegionId
zh-cn: 地域ID
AssociationProperty: RegionId
Type: String
Default: '{{ ACS::RegionId }}'
tags:
Label:
en: Tags
zh-cn: 要添加的新ECS实例的标签
Type: Json
AssociationProperty: Tags
Tasks:
- Name: describeInstances
Action: ACS::ExecuteAPI
Description:
en: Queries the ECS instances by specifying tag
zh-cn: 通过指定标签查看ECS实例
Properties:
Service: ECS
API: DescribeInstances
Parameters:
RegionId: '{{ regionId }}'
Tags: '{{ tags }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
- Action: ACS::ExecuteApi
Name: getSecurityGrpup
Properties:
Service: ECS
API: DescribeSecurityGroups
Parameters:
RegionId: '{{regionId}}'
Tags: '{{ tags }}'
Outputs:
securityGroupId:
Type: String
ValueSelector: .SecurityGroups.SecurityGroup[].SecurityGroupId
OnError: ACS::END
OnSuccess: ACS::NEXT
- Action: ACS::ExecuteApi
Name: addInstancesToSecurityGrpup
Properties:
Service: ECS
API: JoinSecurityGroup
Parameters:
RegionId: '{{regionId}}'
InstanceId: '{{ ACS::TaskLoopItem }}'
SecurityGroupId: '{{ getSecurityGrpup.securityGroupId }}'
Outputs: {}
OnError: ACS::END
OnSuccess: ACS::NEXT
Loop:
Items: '{{ describeInstances.instanceIds }}'
RateControl:
MaxErrors: 0
Mode: Concurrency
Concurrency: 1
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- regionId
- tags
Label:
default:
zh-cn: 选择标签
en: Select Tags
文档内容是否对您有帮助?