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

CloudOps Orchestration Service:複数の ECS インスタンスの課金方法を一括で変更する

最終更新日:Jan 17, 2025

背景情報

ビジネス要件に基づいて、複数の Elastic Compute Service(ECS)インスタンスの課金方法をサブスクリプションから従量課金に、または従量課金からサブスクリプションに変更する必要がある場合があります。複数の ECS インスタンスの課金方法は、手動で 1 つずつ変更できます。ただし、手動操作は非効率的でエラーが発生しやすくなります。このトピックでは、CloudOps Orchestration Service(OOS)を使用して、複数の ECS インスタンスの課金方法を一括で変更する方法について説明します。ECS は、サブスクリプションと従量課金の課金方法をサポートしています。詳細については、「サブスクリプション」および「従量課金」をご参照ください。

前提条件

  1. ECS インスタンスの課金方法をサブスクリプションから従量課金に変更するための前提条件については、「インスタンスの課金方法をサブスクリプションから従量課金に変更する」をご参照ください。

  2. ECS インスタンスの課金方法を従量課金からサブスクリプションに変更するための前提条件については、「インスタンスの課金方法を従量課金からサブスクリプションに変更する」をご参照ください。

手順

  1. OOS コンソールにログインします。

  2. 左側のナビゲーションウィンドウで、自動タスク > パブリックテンプレート を選択します。

  3. 検索ボックスに ACS-ECS-BulkyModifyInstanceChargeType と入力し、[検索] アイコンをクリックします。ACS-ECS-BulkyModifyInstanceChargeType テンプレートの [実行の作成] をクリックします。Screenshot 2023-04-11 at 16.18.04.png

  4. [タスクの作成] ページで、[基本情報] ステップで必要なパラメーターを構成し、次の手順: パラメーター設定image.png をクリックします。

  5. [パラメーター設定] ステップで、次のパラメーターを構成します。

    1. InstanceChargeType: インスタンスの新しい課金方法。

      1. Period: インスタンスのサブスクリプション期間。 InstanceChargeType として PrePaid を選択した場合は、このパラメーターが必要です。 PeriodUnit として Week を選択した場合、Period パラメーターの有効な値は 1 ~ 4 です。 PeriodUnit として Month を選択した場合、Period パラメーターの有効な値は 1 ~ 12、24、36、48、60 です。

      2. PeriodUnit: サブスクリプション期間の時間単位。 InstanceChargeType として PrePaid を選択した場合は、このパラメーターが必要です。

    2. IncludeDataDisks: インスタンスに接続されているすべてのデータディスクの課金方法を従量課金からサブスクリプションに変更するかどうかを指定します。 InstanceChargeType として PrePaid を選択した場合は、このパラメーターが必要です。

    3. NetworkChargeType: ネットワーク使用量の新しい課金方法。

    4. RegionId: リージョンの ID。

    5. TargetInstance: 課金方法を変更するインスタンス。

    6. RateControl: オプション。実行の同時実行構成。

    7. OOSAssumeRole: オプション。OOS がアシュームする Resource Access Management(RAM)ロール。Screenshot 2023-04-11 at 16.38.42.png

  6. [次のステップ: OK] をクリックします。 次のステップ: OK作成 ステップで、 をクリックします。

  7. 左側のナビゲーションウィンドウで、自動タスク > [タスク実行管理] を選択します。 タスク実行管理 ページで、作成された実行を見つけます。実行が実行中状態の場合、指定された ECS インスタンスの課金方法が変更されています。

  8. 実行の状態が成功に変更されると、指定された ECS インスタンスの課金方法が変更されます。 ECS インスタンスの新しい課金方法は、ECS コンソールの [インスタンス] ページで確認できます。

  9. ECS インスタンスの課金方法の変更プロセスに関する詳細を表示するには、[アクション] 列の 詳細 をクリックして実行ログを表示します。その後、実行の進捗状況とステータスをリアルタイムで確認できます。

付録

パブリックテンプレート ACS-ECS-BulkyModifyInstanceChargeType

FormatVersion: OOS-2019-06-01
Description:
  en: Bulky modify instance charge type
   
  name-en: ACS-ECS-BulkyModifyInstanceChargeType
   
  categories:
    - instance_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
       
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Type: Json
    Label:
      en: TargetInstance
       
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: regionId
  instanceChargeType:
    Label:
      en: InstanceChargeType
       
    Type: String
    AllowedValues:
      - PostPaid
      - PrePaid
    Default: PostPaid
  periodUnit:
    Label:
      en: PeriodUnit
       
    Type: String
    AllowedValues:
      - Week
      - Month
    Default: Month
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${instanceChargeType}
              - PostPaid
  period:
    Description:
      en: The period of the instance
       
    Label:
      en: Period
       
    Type: Number
    Default: 1
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${instanceChargeType}
              - PostPaid
  includeDataDisks:
    Description:
      en: Specifies whether to change the billing method of all data disks attached to the instance from pay-as-you-go to subscription
       
    Label:
      en: IncludeDataDisks
       
    Type: Boolean
    Default: false
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${instanceChargeType}
              - PostPaid
  networkChargeType:
    Label:
      en: NetworkChargeType
       
    Type: String
    AllowedValues:
      - PayByBandwidth
      - PayByTraffic
      - ''
    Default: PayByTraffic
  rateControl:
    Label:
      en: RateControl
       
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
       
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances
       
    Action: ACS::SelectTargets
    Properties:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: Instances.Instance[].InstanceId
  - Name: modifyInstanceChargeType
    Description:
      en: Modify instance charge type
       
    Action: ACS::ECS::ModifyInstanceChargeType
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      instanceChargeType: '{{ instanceChargeType }}'
      networkChargeType: '{{ networkChargeType }}'
      period: '{{ period }}'
      periodUnit: '{{ periodUnit }}'
      includeDataDisks: '{{ includeDataDisks }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - instanceChargeType
          - period
          - periodUnit
          - includeDataDisks
          - networkChargeType
        Label:
          default:
             
            en: Choose the parameter of instnace charge type
      - Parameters:
          - regionId
          - target
        Label:
          default:
             
            en: Select ECS Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
             
            en: Control Options