すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:承認後に ECS インスタンスを実行する

最終更新日:Jan 17, 2025

テンプレート名

ACS-ECS-RunInstancesWithApproval

今すぐ実行

テンプレートの説明

承認後に Elastic Compute Service (ECS) インスタンスを作成します。

テンプレートタイプ

自動化

所有者

Alibaba Cloud

入力パラメーター

パラメーター

説明

タイプ

必須

デフォルト値

制限

accessToken

DingTalk にアクセスするために使用されるトークン。

文字列

はい

文字列検証の正規表現: [A-Za-z0-9]*

imageId

イメージ ID。

文字列

はい

instanceType

ECS インスタンスのインスタンスタイプ。

文字列

はい

文字列検証の正規表現: ecs.[A-Za-z0-9.-]*。

securityGroupId

セキュリティグループ ID。

文字列

はい

vSwitchId

vSwitch ID。

文字列

はい

amount

作成する ECS インスタンスの数。

数値

いいえ

1

OOSAssumeRole

CloudOps Orchestration Service (OOS) によって引き受けられる Resource Access Management (RAM) ロール。

文字列

いいえ

""

出力パラメーター

パラメーター

説明

タイプ

instanceId

文字列

テンプレートを実行するために必要な権限ポリシー

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:RunInstances"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

参照

詳細については、GitHub の ACS-ECS-RunInstancesWithApproval.yml をご参照ください。

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  en: Creates one or more ECS instances with approval
  zh-cn: the description in Chinese
  name-en: ACS-ECS-RunInstancesWithApproval
  name-zh-cn: the description in Chinese
  categories:
    - cost_manage
Parameters:
  accessToken:
    Label:
      en: AccessToken
      zh-cn: the description in Chinese
    Type: String
    AllowedPattern: '[A-Za-z0-9]*'
  imageId:
    Label:
      en: ImageId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Image::ImageId'
  instanceType:
    Label:
      en: InstanceType
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AllowedPattern: ecs\.[A-Za-z0-9\.\-]*
  securityGroupId:
    Label:
      en: SecurityGroupId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::ECS::SecurityGroup::SecurityGroupId'
  vSwitchId:
    Label:
      en: VSwitchId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::VPC::VSwitch::VSwitchId'
    AssociationPropertyMetadata:
      Filters:
        - SecurityGroupId: securityGroupId
  amount:
    Label:
      en: Amount
      zh-cn: the description in Chinese
    Type: Number
    Default: 1
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: approvalForRunInstances
  Action: ACS::Approve
  Description:
    en: Approval to lunch ECS instances
    zh-cn: the description in Chinese
  Properties:
    NotifyType: WebHook
    WebHook:
      URI: https://oapi.dingtalk.com/robot/send?access_token={{ accessToken }}
      Headers:
        Content-Type: application/json
      Content:
        msgtype: text
        text:
          content: The ECS instances will be created
- Name: runInstances
  Action: ACS::ECS::RunInstances
  Description:
    en: Creates one or more ECS instances
    zh-cn: the description in Chinese
  Properties:
    imageId: '{{ imageId }}'
    instanceType: '{{ instanceType }}'
    securityGroupId: '{{ securityGroupId }}'
    vSwitchId: '{{ vSwitchId }}'
    amount: '{{ amount }}'
  Outputs:
    instanceId:
      ValueSelector: instanceIds[0]
      Type: String
Outputs:
  instanceId:
    Type: String
    Value: '{{ runInstances.instanceId }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - accessToken
        Label:
          default:
            zh-cn: the description in Chinese
            en: Dingtalk Access Token
      - Parameters:
          - imageId
          - instanceType
          - securityGroupId
          - vSwitchId
          - amount
        Label:
          default:
            zh-cn: the description in Chinese
            en: Run Command Options
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options