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

CloudOps Orchestration Service:SLB のデフォルトサーバーグループにおける ECS システムディスクの一括交換

最終更新日:Jan 17, 2025

テンプレート名

ACS-ECS-BulkyReplaceSystemDiskInSLBDefaultServerGroup

今すぐ実行

テンプレートの説明

Server Load Balancer (SLB) インスタンスのデフォルトサーバーグループにある複数の Elastic Compute Service (ECS) インスタンスのシステムディスクを一度に交換します。

テンプレートタイプ

自動化

所有者

Alibaba Cloud

入力パラメーター

パラメーター

説明

タイプ

必須

デフォルト値

制限

imageId

ソースイメージの ID です。

String

はい

loadBalancerId

SLB インスタンスの ID です。

String

はい

rateControl

レート制御設定です。

Json

いいえ

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 1}

OOSAssumeRole

CloudOps Orchestration Service (OOS) がアシュームする Resource Access Management (RAM) ロールです。

String

いいえ

""

出力パラメーター

パラメーター

説明

タイプ

newSystemDiskIds

List

テンプレートの実行に必要な権限ポリシー

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "slb:DescribeLoadBalancerAttribute",
                "slb:SetBackendServers"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ecs:DescribeDisks",
                "ecs:DescribeInstances",
                "ecs:ReplaceSystemDisk",
                "ecs:StartInstance",
                "ecs:StopInstance"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

参照

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

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  en: Bulky replaces system disk of ECS instances in default server group
  zh-cn: the description in Chinese
  name-en: ACS-ECS-BulkyReplaceSystemDiskInSLBDefaultServerGroup
  name-zh-cn: the description in Chinese
  categories:
    - slb_management
Parameters:
  imageId:
    Label:
      en: The image ID for the ECS instance
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Image::ImageId'
  loadBalancerId:
    Label:
      en: LoadBalancerId
      zh-cn: the description in Chinese
    Type: String
  rateControl:
    Label:
      en: RateControl
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 1
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: describeLoadBalancerAttribute
    Action: ACS::ExecuteApi
    Description:
      en: Views loadbalancer attribute
      zh-cn: the description in Chinese
    Properties:
      Service: SLB
      API: DescribeLoadBalancerAttribute
      Parameters:
        LoadBalancerId: '{{ loadBalancerId }}'
    Outputs:
      BackendServers:
        Type: List
        ValueSelector: BackendServers.BackendServer[]
      port:
        Type: Number
        ValueSelector: ListenerPorts.ListenerPort[]
  - Name: replaceSystemDisk
    Action: ACS::ECS::ElegantReplaceSystemDiskInSLBDefaultServerGroup
    Description:
      en: Replaces the system disk of ECS instances
      zh-cn: the description in Chinese
    Properties:
      loadBalancerId: '{{ LoadBalancerId }}'
      imageId: '{{ imageId }}'
      serverId:
        'Fn::Select':
          - ServerId
          - '{{ ACS::TaskLoopItem }}'
      weight:
        'Fn::Select':
          - Weight
          - '{{ ACS::TaskLoopItem }}'
      type:
        'Fn::Select':
          - Type
          - '{{ ACS::TaskLoopItem }}'
      port: '{{ describeLoadBalancerAttribute.port }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ describeLoadBalancerAttribute.BackendServers }}'
      Outputs:
        newSystemDiskIds:
          AggregateType: Fn::ListJoin
          AggregateField: newSystemDiskId
    Outputs:
      newSystemDiskId:
        Type: String
        ValueSelector: newSystemDiskId
Outputs:
  newSystemDiskIds:
    Type: List
    Value: '{{ replaceSystemDisk.newSystemDiskIds }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - imageId
          - loadBalancerId
        Label:
          default:
            zh-cn: the description in Chinese
            en: Configure Parameters
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options