全部产品
Search
文档中心

CloudOps Orchestration Service:ACS-ESS-LifeCycleModifyInstanceChargeType

更新时间:Dec 21, 2025

Nama Template

ACS-ESS-LifeCycleModifyInstanceChargeType: Mengubah metode penagihan instans menggunakan kait siklus hidup (hanya untuk aktivitas skala keluar)

Eksekusi Sekarang

Deskripsi Template

Mengubah metode penagihan instans menggunakan kait siklus hidup. Templat ini hanya mendukung aktivitas skala keluar.

Tipe Template

Otomatis

Pemilik

Alibaba Cloud

Parameter Input

Parameter

Deskripsi

Tipe Data

Diperlukan

Nilai Default

Batasan

instanceChargeType

Metode penagihan baru untuk instance.

String

Tidak

PostPaid

periodUnit

Unit durasi perpanjangan instance.

String

Tidak

Bulan

period

Durasi perpanjangan.

Number

Tidak

1

includeDataDisks

Menentukan apakah akan mengubah metode penagihan disk data yang terpasang pada instance.

Boolean

Tidak

False

autoRenew

Menentukan apakah instans diperpanjang secara otomatis sebelum masa berlakunya habis.

Boolean

Tidak

False

networkChargeType

Metode penagihan baru untuk jaringan.

String

Tidak

PayByTraffic

lifecycleActionResult

Aksi yang diambil setelah status tunggu kait siklus hidup berakhir.

String

Tidak

${lifecycleActionResult}

regionId

ID wilayah.

String

Tidak

${regionId}

instanceIds

Daftar ID Instance ECS.

List

Tidak

${instanceIds}

OOSAssumeRole

Peran RAM OOS

String

Tidak

""

rateControl

Laju eksekusi tugas secara konkuren.

Json

Tidak

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

lifecycleActionToken

Token untuk aktivitas penskalaan yang terkait dengan instans.

String

Tidak

${lifecycleActionToken}

OOSAssumeRole

Peran RAM yang diasumsikan oleh OOS.

String

Tidak

""

Parameter keluaran

Tidak ada.

Kebijakan izin yang diperlukan untuk mengeksekusi template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:ModifyInstanceAutoRenewAttribute",
                "ecs:ModifyInstanceChargeType",
                "ecs:ModifyInstanceNetworkSpec"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ess:CompleteLifecycleAction"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Rincian

ACS-ESS-LifeCycleModifyInstanceChargeType

Konten Template

FormatVersion: OOS-2019-06-01
Description:
  en: Uses a lifecycle hook to change the instance billing method during a scale-out activity.
  zh-cn: Uses a lifecycle hook to change the instance billing method (for scale-out activities only).
  name-en: ACS-ESS-LifeCycleModifyInstanceChargeType
  name-zh-cn: UseLifecycleHookToChangeInstanceBillingMethodForScaleOut
  categories:
    - elastic_manage
Parameters:
  instanceChargeType:
    Label:
      en: InstanceChargeType
      zh-cn: Target billing method for the instance
    Type: String
    AllowedValues:
      - PostPaid
      - PrePaid
    Default: PostPaid
  periodUnit:
    Label:
      en: PeriodUnit
      zh-cn: Time unit for the renewal period
    Type: String
    AllowedValues:
      - Week
      - Month
    Default: Month
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${instanceChargeType}
              - PostPaid
  period:
    Description:
      en: The subscription period of the instance.
      zh-cn: If PeriodUnit is Week, the valid values for Period are 1 to 4. If PeriodUnit is Month, the valid values for Period are 1 to 12, 24, 36, 48, and 60.
    Label:
      en: Period
      zh-cn: Renewal 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.
      zh-cn: Specifies whether to convert all attached pay-as-you-go data disks to subscription data disks.
    Label:
      en: IncludeDataDisks
      zh-cn: Convert data disks
    Type: Boolean
    Default: false
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${instanceChargeType}
              - PostPaid
  autoRenew:
    Description:
      en: Specifies whether to automatically renew the instance before it expires.
      zh-cn: Specifies whether to automatically renew the instance before it expires.
    Label:
      en: AutoRenew
      zh-cn: Enable auto-renewal before expiration
    Type: Boolean
    Default: false
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Not:
            Fn::Equals:
              - ${instanceChargeType}
              - PostPaid
  networkChargeType:
    Label:
      en: NetworkChargeType
      zh-cn: Target billing method for the network
    Type: String
    AllowedValues:
      - PayByBandwidth
      - PayByTraffic
    Default: PayByTraffic
  lifecycleActionResult:
    Label:
      en: LifecycleActionResult
      zh-cn: Next action after the lifecycle hook wait state ends
    Description:
      en: The next action for the lifecycle hook after its wait state ends, if the command fails.
      zh-cn: The next action for the lifecycle hook after its wait state ends, if the command fails.
    Type: String
    AllowedValues:
      - ABANDON
      - ROLLBACK
      - CONTINUE
    Default: ABANDON
  regionId:
    Label:
      en: RegionId
      zh-cn: Region ID
    Description:
      en: The ID of the region.
      zh-cn: The region ID. Use the default value ${regionId} from Auto Scaling.
    Type: String
    Default: ${regionId}
  instanceIds:
    Label:
      en: InstanceIds
      zh-cn: List of ECS instance IDs
    Description:
      en: The list of ECS instance IDs.
      zh-cn: The list of ECS instance IDs. Use the default value ["${instanceId}"] from Auto Scaling.
    Type: List
    Default:
      - ${instanceIds}
  lifecycleHookId:
    Label:
      en: LifecycleHookId
      zh-cn: Lifecycle hook ID
    Description:
      en: The ID of the lifecycle hook.
      zh-cn: The ID of the lifecycle hook. Use the default value ${lifecycleHookId} from Auto Scaling.
    Type: String
    Default: ${lifecycleHookId}
  rateControl:
    Label:
      en: RateControl
      zh-cn: Concurrency rate for task execution
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  lifecycleActionToken:
    Label:
      en: LifecycleActionToken
      zh-cn: Token for the scaling activity associated with the instance
    Description:
      en: The token that indicates a specific scaling activity associated with an instance.
      zh-cn: The token for the specific scaling activity associated with the instance. Use the default value ${lifecycleActionToken} from Auto Scaling.
    Type: String
    Default: ${lifecycleActionToken}
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: RAM role assumed by OOS
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: sleepTask
    Action: ACS::Sleep
    Properties:
      Duration: 10s
  - Name: modifyInstanceChargeType
    OnError: CompleteLifecycleActionForAbandon
    Description:
      en: Modifies the instance billing method.
      zh-cn: Change instance billing method
    Action: ACS::ECS::ModifyInstanceChargeType
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      instanceChargeType: '{{ instanceChargeType }}'
      networkChargeType: '{{ networkChargeType }}'
      period: '{{ period }}'
      periodUnit: '{{ periodUnit }}'
      includeDataDisks: '{{ includeDataDisks }}'
    Loop:
      Items: '{{ instanceIds }}'
      RateControl: '{{ rateControl }}'
  - Name: modifyInstanceAutoRenewAttribute
    OnError: CompleteLifecycleActionForAbandon
    OnSuccess: CompleteLifecycleActionForContinue
    Description:
      en: Modifies the auto-renewal settings of the instance.
      zh-cn: Set auto-renewal status for subscription instances
    Action: ACS::ECS::ModifyInstanceAutoRenewAttribute
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      autoRenew: '{{ autoRenew }}'
      duration: '{{ period }}'
      periodUnit: '{{ periodUnit }}'
    Loop:
      Items: '{{ instanceIds }}'
      RateControl: '{{ rateControl }}'
    When:
      Fn::Equals:
        - '{{ autoRenew }}'
        - true
  - Name: CompleteLifecycleActionForContinue
    Action: ACS::ExecuteAPI
    Description:
      en: Sets the lifecycle action to CONTINUE.
      zh-cn: Change the wait state of the scaling activity to CONTINUE
    OnSuccess: ACS::END
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: CONTINUE
  - Name: CompleteLifecycleActionForAbandon
    Action: ACS::ExecuteAPI
    Description:
      en: Sets the lifecycle action to ABANDON.
      zh-cn: Change the wait state of the scaling activity to ABANDON
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: '{{ lifecycleActionResult }}'