Changes the billing method of ECS instances during a scale-out activity by using a lifecycle hook.
Template name
ACS-ESS-LifeCycleModifyInstanceChargeType: Changes the billing method of an instance using a lifecycle hook (for scale-out activities only)
Template description
Uses a lifecycle hook to change the billing method of an instance. Only scale-out activities are supported.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
|
Parameter |
Description |
Data type |
Required |
Default value |
Limit |
|
instanceChargeType |
The new billing method of the instances. |
String |
No |
PostPaid |
|
|
periodUnit |
The unit of the renewal duration of the instances. |
String |
No |
Month |
|
|
period |
The renewal duration. |
Number |
No |
1 |
|
|
includeDataDisks |
Whether to change the billing method of data disks attached to the instances. |
Boolean |
No |
False |
|
|
autoRenew |
Whether to automatically renew the instance before it expires. |
Boolean |
No |
False |
|
|
networkChargeType |
The new billing method for the network. |
String |
No |
PayByTraffic |
|
|
lifecycleActionResult |
The action to take after the lifecycle hook wait state ends. |
String |
No |
${lifecycleActionResult} |
|
|
regionId |
The region ID. |
String |
No |
${regionId} |
|
|
instanceIds |
The list of ECS instance IDs. |
List |
No |
${instanceIds} |
|
|
OOSAssumeRole |
The RAM role to be assumed by OOS. |
String |
No |
"" |
|
|
rateControl |
The concurrency rate for task execution. |
Json |
No |
{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} |
|
|
lifecycleActionToken |
The token for the scaling activity associated with the instance. |
String |
No |
${lifecycleActionToken} |
|
|
OOSAssumeRole |
The RAM role assumed by OOS. |
String |
No |
"" |
Output parameters
N/A.
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:ModifyInstanceAutoRenewAttribute",
"ecs:ModifyInstanceChargeType",
"ecs:ModifyInstanceNetworkSpec"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ess:CompleteLifecycleAction"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
ACS-ESS-LifeCycleModifyInstanceChargeType
Template content
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 }}'