Baixe um arquivo para instâncias ECS e execute um comando usando um lifecycle hook do Auto Scaling.
Nome do modelo
ACS-ESS-LifeCycleDownloadFileAndRunCommand
Descrição do modelo
Baixa um arquivo para instâncias do Elastic Compute Service (ECS) e executa um comando nessas instâncias por meio de um lifecycle hook.
Tipo de modelo
Automatizado
Proprietário
Alibaba Cloud
Parâmetros de entrada
|
Parâmetro |
Descrição |
Tipo |
Obrigatório |
Valor padrão |
Limite |
|
sourcePath |
URL do arquivo para download. |
String |
Sim |
||
|
destinationDir |
Diretório de destino na instância ECS. |
String |
Sim |
||
|
whetherSaveToFile |
Indica se o conteúdo baixado deve ser salvo em um arquivo. |
Boolean |
Não |
True |
|
|
commandContent |
Comando do Cloud Assistant para execução na instância ECS. |
String |
Não |
echo hello |
|
|
timeout |
Tempo limite para execução do comando. |
Number |
Não |
600 |
|
|
regionId |
ID da região. |
String |
Não |
${regionId} |
|
|
instanceIds |
IDs das instâncias ECS. |
List |
Não |
['${instanceIds}'] |
|
|
lifecycleHookId |
ID do lifecycle hook. |
String |
Não |
${lifecycleHookId} |
|
|
lifecycleActionToken |
Token da atividade de dimensionamento associada à instância. |
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
Nenhum
Política de permissões necessária
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ess:CompleteLifecycleAction"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Referências
Para mais informações, consulte ACS-ESS-LifeCycleDownloadFileAndRunCommand.yml no GitHub.
Conteúdo do modelo
FormatVersion: OOS-2019-06-01
Description:
en: Use lifecycleHook to download file and run command in the specified scaling activity instance
name-en: ACS-ESS-LifeCycleDownloadFileAndRunCommand
categories:
- elastic_manage
Parameters:
sourcePath:
Type: String
Label:
en: SourcePath
destinationDir:
Label:
en: DestinationDir
Type: String
whetherSaveToFile:
Label:
en: whetherSaveToFile
Type: Boolean
Default: true
commandContent:
Label:
en: CommandContent
Type: String
AssociationProperty: Code
Default: echo hello
timeout:
Label:
en: Timeout
Type: Number
Default: 600
regionId:
Label:
en: RegionId
Description:
en: The ID of region
Type: String
Default: '${regionId}'
instanceIds:
Label:
en: InstanceIds
Description:
en: The ID list of the ECS instance
Type: List
Default:
- '${instanceIds}'
lifecycleHookId:
Label:
en: LifecycleHookId
Description:
en: The ID of the lifecycle hook
Type: String
Default: '${lifecycleHookId}'
lifecycleActionToken:
Label:
en: LifecycleActionToken
Description:
en: The token that indicates a specific scaling activity associated with an instance
Type: String
Default: '${lifecycleActionToken}'
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: downloadFileAndRunCommand
OnError: CompleteLifecycleActionForAbandon
OnSuccess: CompleteLifecycleActionForContinue
Action: ACS::ESS::DownloadFileAndRunCommand
Description:
en: Downloads file to the ECS instances adn run command
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
sourceType: https
sourcePath: '{{ sourcePath }}'
destinationDir: '{{ destinationDir }}'
whetherSaveToFile: '{{ whetherSaveToFile }}'
commandContent: '{{ commandContent }}'
timeout: '{{ timeout }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ instanceIds }}'
- Name: CompleteLifecycleActionForContinue
Action: 'ACS::ExecuteAPI'
Description:
en: Modify lifecycle action for 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: Complete lifecycle action for Abandon
Properties:
Service: ESS
API: CompleteLifecycleAction
Parameters:
RegionId: '{{ regionId }}'
LifecycleHookId: '{{ lifecycleHookId }}'
LifecycleActionToken: '{{ lifecycleActionToken }}'
LifecycleActionResult: ABANDON