Execute comandos em instâncias ECS usando ganchos de ciclo de vida do Auto Scaling.
Nome do modelo
O modelo ACS-ESS-LifeCycleRunCommand executa um comando em uma instância por meio de um gancho de ciclo de vida.
Descrição do modelo
Usa um gancho de ciclo de vida para executar comandos em instâncias do Elastic Compute Service (ECS).
Tipo de modelo
Automatizado
Proprietário
Alibaba Cloud
Parâmetros de entrada
|
Parâmetro |
Descrição |
Tipo |
Obrigatório |
Valor padrão |
Limite |
|
commandType |
Tipo dos comandos do Cloud Assistant. |
String |
Não |
RunShellScript |
|
|
commandContent |
Conteúdo dos comandos do Cloud Assistant. |
String |
Não |
echo hello |
|
|
timeout |
Tempo limite em segundos. |
Number |
Não |
600 |
|
|
lifecycleActionResult |
Ação subsequente após o fim do estado de espera do gancho de ciclo de vida. |
String |
Não |
ABANDON |
|
|
regionId |
ID da região. |
String |
Não |
${regionId} |
|
|
instanceIds |
IDs das instâncias ECS. |
List |
Não |
['${instanceIds}'] |
|
|
lifecycleHookId |
ID do gancho de ciclo de vida. |
String |
Não |
${lifecycleHookId} |
|
|
lifecycleActionToken |
Token da atividade de dimensionamento específica associada às instâncias. |
String |
Não |
${lifecycleActionToken} |
|
|
rateControl |
Configurações de controle de taxa. |
Json |
Não |
{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} |
|
|
OOSAssumeRole |
Função RAM assumida pelo CloudOps Orchestration Service (OOS). |
String |
Não |
OOSServiceRole |
Parâmetros de saída
|
Parâmetro |
Descrição |
Tipo |
|
commandOutputs |
List |
Política necessária para executar o modelo
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ess:CompleteLifecycleAction"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Detalhes
Conteúdo do modelo
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 }}'