Nama template
ACS-ESS-LifeCycleRunCommand mengeksekusi perintah pada instance menggunakan kait siklus hidup.
Deskripsi template
Gunakan hook siklus hidup untuk menjalankan perintah pada instance Elastic Compute Service (ECS).
Tipe template
Otomatis
Pemilik
Alibaba Cloud
Parameter input
Parameter | Deskripsi | Tipe | Diperlukan | Nilai default | Batasan |
commandType | Tipe perintah Asisten Cloud. | String | Tidak | RunShellScript | |
commandContent | Konten dari perintah Asisten Cloud. | String | Tidak | echo hello | |
timeout | Periode timeout dalam detik. | Number | Tidak | 600 | |
lifecycleActionResult | Aksi berikutnya setelah status tunggu kait siklus hidup berakhir | String | Tidak | ABANDON | |
regionId | ID wilayah. | String | Tidak | ${regionId} | |
instanceIds | ID instance ECS. | List | Tidak | ['${instanceIds}'] | |
lifecycleHookId | ID hook siklus hidup. | String | Tidak | ${lifecycleHookId} | |
lifecycleActionToken | Token aktivitas penskalaan tertentu yang terkait dengan instance. | String | Tidak | ${lifecycleActionToken} | |
rateControl | Pengaturan kontrol laju. | Json | Tidak | {'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} | |
OOSAssumeRole | Peran Resource Access Management (RAM) yang diasumsikan oleh CloudOps Orchestration Service (OOS). | String | Tidak | OOSServiceRole |
Parameter output
Parameter | Deskripsi | Tipe |
commandOutputs | List |
Kebijakan yang diperlukan untuk mengeksekusi template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ess:CompleteLifecycleAction"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Detail
Konten Template
FormatVersion: OOS-2019-06-01
Description:
en: Uses a lifecycle hook to run a command on an instance in a specified scaling activity.
zh-cn: Uses a lifecycle hook to run a command on an instance in a specified scaling activity.
name-en: ACS-ESS-LifeCycleRunCommand
name-zh-cn: Use a lifecycle hook to run a command in an instance
categories:
- elastic_manage
Parameters:
commandType:
Label:
en: CommandType
zh-cn: Command type
Type: String
AllowedValues:
- RunBatScript
- RunPowerShellScript
- RunShellScript
Default: RunShellScript
commandContent:
Label:
en: CommandContent
zh-cn: Command content
Type: String
AssociationProperty: Code
Default: echo hello
timeout:
Label:
en: Timeout (s)
zh-cn: Timeout (s)
Type: Number
Default: 600
lifecycleActionResult:
Label:
en: LifecycleActionResult
zh-cn: Next action after wait state ends
Description:
en: The next action to perform after the wait state ends if the command fails.
zh-cn: The next action to perform after the 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. Use the Auto Scaling default value: ${regionId}
zh-cn: The ID of the region. Use the Auto Scaling default value: ${regionId}
Type: String
Default: '${regionId}'
instanceIds:
Label:
en: InstanceIds
zh-cn: List of ECS instance IDs
Description:
en: The list of ECS instance IDs. Use the Auto Scaling default value: ["${instanceId}"]
zh-cn: The list of ECS instance IDs. Use the Auto Scaling default value: ["${instanceId}"]
Type: List
Default:
- '${instanceIds}'
lifecycleHookId:
Label:
en: LifecycleHookId
zh-cn: Lifecycle hook ID
Description:
en: The ID of the lifecycle hook. Use the Auto Scaling default value: ${lifecycleHookId}
zh-cn: The ID of the lifecycle hook. Use the Auto Scaling default value: ${lifecycleHookId}
Type: String
Default: '${lifecycleHookId}'
lifecycleActionToken:
Label:
en: LifecycleActionToken
zh-cn: Token for a specific scaling activity
Description:
en: The token for the specific scaling activity associated with an instance. Use the Auto Scaling default value: ${lifecycleActionToken}
zh-cn: The token for the specific scaling activity associated with an instance. Use the Auto Scaling default value: ${lifecycleActionToken}
Type: String
Default: '${lifecycleActionToken}'
rateControl:
Label:
en: RateControl
zh-cn: Rate control
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: RAM role assumed by OOS
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: runCommand
Action: ACS::ECS::RunCommand
OnError: CompleteLifecycleActionForAbandon
OnSuccess: CompleteLifecycleActionForContinue
Description:
en: Executes a Cloud Assistant command.
zh-cn: Executes a Cloud Assistant command.
Properties:
regionId: '{{ regionId }}'
commandContent: '{{ commandContent }}'
instanceId: '{{ ACS::TaskLoopItem }}'
commandType: '{{ commandType }}'
timeout: '{{ timeout }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ instanceIds }}'
Outputs:
commandOutputs:
AggregateType: Fn::ListJoin
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: invocationOutput
- Name: CompleteLifecycleActionForContinue
Action: 'ACS::ExecuteAPI'
Description:
en: Changes the wait state of the scaling activity to CONTINUE.
zh-cn: Changes 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: Ends the lifecycle action with the specified result on failure.
zh-cn: Ends the lifecycle action with the specified result on failure.
Properties:
Service: ESS
API: CompleteLifecycleAction
Parameters:
RegionId: '{{ regionId }}'
LifecycleHookId: '{{ lifecycleHookId }}'
LifecycleActionToken: '{{ lifecycleActionToken }}'
LifecycleActionResult: '{{ lifecycleActionResult }}'
Outputs:
commandOutputs:
Type: List
Value: '{{ runCommand.commandOutputs }}'