テンプレート名
ACS-ECS-ApproveROSCreateInstances
テンプレートの説明
承認後に Resource Orchestration Service (ROS) を使用して Elastic Compute Service (ECS) インスタンスを作成します。
テンプレートタイプ
自動化
所有者
Alibaba Cloud
入力パラメーター
パラメーター | 説明 | タイプ | 必須 | デフォルト値 | 制限 |
imageId | ECS インスタンスの作成に使用するイメージの ID。 | String | はい | ||
instanceType | 作成する ECS インスタンスのインスタンスタイプ。 | String | はい | ||
zoneId | vSwitch を作成するゾーンの ID。 | String | はい | ||
webHookUrl | DingTalk チャットボットの Webhook URL。 | String | はい | ||
atMobiles | 指定された DingTalk グループに承認通知が送信されたときに通知されるメンバー。 | List | はい | ||
approvers | タスクを承認できるユーザー。 | List | はい | ||
instancesCount | 作成する ECS インスタンスの数。 | Number | はい | ||
regionId | リージョン ID。 | String | いいえ | {{ ACS::RegionId }} | |
atAll | 指定された DingTalk グループに承認通知が送信されたときに、すべてのグループメンバーに通知するかどうかを指定します。 | String | いいえ | false | |
minRequiredApprovals | タスクの承認に必要な承認者の最小数。 | Number | いいえ | 1 | |
OOSAssumeRole | CloudOps Orchestration Service (OOS) によって引き受けられる Resource Access Management (RAM) ロール。 | String | いいえ | "" |
出力パラメーター
パラメーター | 説明 | タイプ |
instanceIds | List |
テンプレートの実行に必要な権限ポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"ros:CreateStack",
"ros:DeleteStack",
"ros:GetStack"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
参照
詳細については、GitHub の ACS-ECS-ApproveROSCreateInstances.yml をご参照ください。
テンプレートコンテンツ
FormatVersion: OOS-2019-06-01
Description:
en: Create ECS instances by ROS with approval
zh-cn: 中国語の説明
name-en: ACS-ECS-ApproveROSCreateInstances
name-zh-cn: 中国語の説明
categories:
- cost_manage
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: 中国語の説明
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
imageId:
Label:
en: ImageId
zh-cn: 中国語の説明
Type: String
AssociationProperty: 'ALIYUN::ECS::Image::ImageId'
AssociationPropertyMetadata:
RegionId: regionId
instanceType:
Label:
en: InstanceType
zh-cn: 中国語の説明
Type: String
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
zoneId:
Label:
en: ZoneId
zh-cn: 中国語の説明
AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
Type: String
AssociationPropertyMetadata:
RegionId: regionId
webHookUrl:
Label:
en: WebHookUrl
zh-cn: 中国語の説明
Description:
en: >-
e.g.https://oapi.dingtalk.com/robot/send?access_token=1234zxcvaksdq31414,acquiring DingTalk webhook please refer to second appendix in https://help.aliyun.com/document_detail/144679.html.
zh-cn: >-
中国語の説明
Type: String
atMobiles:
Label:
en: AtMobiles
zh-cn: 中国語の説明
Type: List
atAll:
Label:
en: AtAll
zh-cn: 中国語の説明
Type: String
Default: 'false'
approvers:
Label:
en: Approvers
zh-cn: 中国語の説明
Description:
en: the name to fill is the front part of @ in the RAM user name,if RAM user is user***@companyAlias.onaliyun.com, then fill user001 in list.
zh-cn: 中国語の説明
Type: List
AssociationProperty: ALIYUN::RAM::User
minRequiredApprovals:
Label:
en: MinRequiredApprovals
zh-cn: 中国語の説明
Type: Number
Default: 1
instancesCount:
Label:
en: InstancesCount
zh-cn: 中国語の説明
Type: Number
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: 中国語の説明
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: approveCreateInstances
Action: 'ACS::Approve'
Description:
en: Approve task creating ECS instances
zh-cn: 中国語の説明
Properties:
Approvers: '{{approvers}}'
MinRequiredApprovals: '{{minRequiredApprovals}}'
NotifyType: WebHook
WebHook:
URI: '{{webhookUrl}}'
Headers:
Content-Type: application/json
Content:
msgtype: text
text:
content: >-
{{ACS::RegionId}} oos {{ACS::ExecutionId}} によって送信された ECS インスタンスを作成するためのタスク実行を承認してください。
at:
atMobiles: '{{atMobiles}}'
isAtAll: '{{atAll}}'
- Name: createStack
Action: 'ACS::ExecuteAPI'
Description:
en: Create a resource stack
zh-cn: 中国語の説明
Properties:
Service: ROS
API: CreateStack
Parameters:
RegionId: '{{ regionId }}'
StackName: 'OOS-{{ACS::ExecutionId}}'
TimeoutInMinutes: 10
DisableRollback: false
Parameters:
- ParameterKey: instanceType
ParameterValue: '{{ instanceType }}'
- ParameterKey: zoneId
ParameterValue: '{{ zoneId }}'
- ParameterKey: regionId
ParameterValue: '{{ regionId }}'
- ParameterKey: imageId
ParameterValue: '{{imageId}}'
- ParameterKey: executionId
ParameterValue: '{{ ACS::ExecutionId }}'
- ParameterKey: instancesCount
ParameterValue: '{{ instancesCount }}'
TemplateBody: |
{
"Description": "VPC ECS インスタンスを作成する",
"Parameters": {
"imageId": {
"Type": "String"
},
"instanceType": {
"Type": "String"
},
"executionId": {
"Type": "String"
},
"instancesCount": {
"Type": "String"
},
"zoneId": {
"Type": "String"
},
"regionId": {
"Type": "String"
},
"resourcePrefix": {
"Type": "String",
"Default": "oos-generated"
}
},
"ROSTemplateFormatVersion": "2015-09-01",
"Outputs": {
"ecs_instance_id": {
"Value": {
"Fn::GetAtt": [
"ecs",
"InstanceIds"
]
}
}
},
"Resources": {
"vswitch": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "vpc"
},
"Description": {
"Fn::Join": [
" ",
[
"OOS 実行 ID は",
{
"Ref": "executionId"
}
]
]
},
"ZoneId": {
"Ref": "zoneId"
},
"CidrBlock": "192.168.0.0/16"
}
},
"sg": {
"Type": "ALIYUN::ECS::SecurityGroup",
"Properties": {
"Tags": [
{
"Key": "oos-generated",
"Value": {
"Ref": "executionId"
}
},
{
"Key": "region",
"Value": {
"Ref": "regionId"
}
}
],
"VpcId": {
"Ref": "vpc"
},
"SecurityGroupName": {
"Fn::Join": [
"-",
[
{
"Ref": "resourcePrefix"
},
"sg"
]
]
},
"SecurityGroupEgress": [
{
"PortRange": "-1/-1",
"Priority": 1,
"IpProtocol": "all",
"DestCidrIp": "0.0.0.0/0",
"NicType": "intranet"
}
]
}
},
"vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": "192.168.0.0/16",
"Description": {
"Fn::Join": [
" ",
[
"OOS 実行 ID は",
{
"Ref": "executionId"
}
]
]
},
"VpcName": {
"Fn::Join": [
"-",
[
{
"Ref": "resourcePrefix"
},
"vpc"
]
]
}
}
},
"ecs": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"ImageId": {
"Ref": "imageId"
},
"SecurityGroupId": {
"Ref": "sg"
},
"VpcId": {
"Ref": "vpc"
},
"VSwitchId": {
"Ref": "vswitch"
},
"InstanceType": {
"Ref": "instanceType"
},
"MinAmount": {
"Ref": "instancesCount"
},
"MaxAmount": {
"Ref": "instancesCount"
},
"Tags": [
{
"Key": "oos-generated",
"Value": {
"Ref": "executionId"
}
},
{
"Key": "region",
"Value": {
"Ref": "regionId"
}
}
]
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"TemplateTags": [
"acs:integrate:oos:ecs_approve_ros_create_instances"
]
}
}
}
Outputs:
StackId:
Type: String
ValueSelector: StackId
- Name: untilStackReady
OnSuccess: ACS::END
OnError: queryStackStatusReason
Action: 'ACS::WaitFor'
Description:
en: Wait for the stack status CREATE_COMPLETE
zh-cn: 中国語の説明
Properties:
Service: ROS
API: GetStack
Parameters:
RegionId: '{{ regionId }}'
StackId: '{{createStack.StackId}}'
DesiredValues:
- CREATE_COMPLETE
StopRetryValues:
- CREATE_FAILED
- CHECK_FAILED
- ROLLBACK_FAILED
- ROLLBACK_COMPLETE
- CREATE_ROLLBACK_COMPLETE
PropertySelector: Status
Outputs:
instanceIds:
Type: String
ValueSelector: 'Outputs[0].OutputValue'
- Name: queryStackStatusReason
Action: ACS::ExecuteAPI
OnError: deleteStack
OnSuccess: deleteStack
Description:
en: Query the reson of failed created stack
zh-cn: 中国語の説明
Properties:
Service: ROS
API: GetStack
Parameters:
RegionId: '{{ regionId }}'
StackId: '{{createStack.StackId}}'
Outputs:
statusReason:
Type: String
ValueSelector: 'StatusReason'
- Name: deleteStack
Action: 'ACS::ExecuteApi'
Description:
en: Delete the stack
zh-cn: 中国語の説明
Properties:
Service: ROS
API: DeleteStack
Parameters:
RegionId: '{{ regionId }}'
StackId: '{{createStack.StackId}}'
Outputs:
instanceIds:
Type: List
Value: '{{ untilStackReady.instanceIds }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- webHookUrl
- atMobiles
- atAll
- approvers
- minRequiredApprovals
Label:
default:
zh-cn: 中国語の説明
en: Configure Approval
- Parameters:
- regionId
- zoneId
- imageId
- instanceType
- instancesCount
Label:
default:
zh-cn: 中国語の説明
en: Configure ECS Instance
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: 中国語の説明
en: Control Options