Todos os produtos
Search
Central de documentação

CloudOps Orchestration Service:ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand

Última atualização: Jun 28, 2026

Usa um lifecycle hook do Auto Scaling para baixar um arquivo do OSS em instâncias ECS e executar comandos.

Nome do modelo

ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand — Baixa um arquivo do OSS para uma instância ECS e executa um comando por meio de um lifecycle hook.

Executar agora

Descrição do modelo

Baixa um objeto do Object Storage Service (OSS) para instâncias do Elastic Compute Service (ECS) por meio de um lifecycle hook e executa comandos nessas instâncias.

Tipo de modelo

Automatizado

Proprietário

Alibaba Cloud

Parâmetros de entrada

Parâmetro

Descrição

Tipo

Obrigatório

Valor padrão

Limite

bucketName

Nome do bucket do OSS.

String

Sim

objectName

Nome do objeto do OSS.

String

Sim

destinationDir

Diretório de destino na instância.

String

Sim

URLExpirationTime

Período de validade da URL de baixe do objeto do OSS.

Number

Não

6000

OSSRegion

Região do bucket do OSS.

String

Não

{{ ACS::RegionId }}

whetherSaveToFile

Indica se o conteúdo deve ser salve em um arquivo local.

Boolean

Não

True

commandContent

Comandos do Cloud Assistant para execute na instância.

String

Não

echo hello

timeout

Tempo limite de execute do comando, em segundos.

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 à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 OOS.

String

Não

OOSServiceRole

Parâmetros de saída

Nenhum

Permissões necessárias

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "oss:GetObject"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ess:CompleteLifecycleAction"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Detalhes

ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand

Conteúdo do modelo

FormatVersion: OOS-2019-06-01
Description:
  en: Uses a lifecycle hook to download an OSS file to the ECS instance of a specified scaling activity and run a command.
  zh-cn: Uses a lifecycle hook to download an OSS file to the ECS instance of a specified scaling activity and run a command.
  name-en: ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand
  name-zh-cn: Uses a lifecycle hook to download an OSS file to an ECS instance and run a command.
  categories:
    - elastic_manage
Parameters:
  bucketName:
    Label:
      en: BucketName
      zh-cn: The name of the OSS bucket.
    Type: String
  objectName:
    Label:
      en: ObjectName
      zh-cn: The name of the OSS object.
    Type: String
  URLExpirationTime:
    Label:
      en: OSSFileDownloadURLExpirationTime
      zh-cn: The expiration time of the OSS file download URL.
    Description:
      en: The time-to-live (TTL), in seconds, for the download URL of the OSS object.
      zh-cn: The time-to-live (TTL), in seconds, for the download URL of the OSS object.
    Type: Number
    Default: 6000
  OSSRegion:
    Label:
      en: OSSRegion
      zh-cn: The region where the OSS bucket is located.
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  destinationDir:
    Label:
      en: DestinationDir
      zh-cn: The destination directory on the instance to which the file is copied.
    Type: String
  whetherSaveToFile:
    Label:
      en: whetherSaveToFile
      zh-cn: Specifies whether to download the content to a specific file.
    Type: Boolean
    Default: true
  commandContent:
    Label:
      en: CommandContent
      zh-cn: The Cloud Assistant command to run on the ECS instance.
    Type: String
    AssociationProperty: Code
    Default: echo hello
  timeout:
    Label:
      en: Timeout
      zh-cn: The timeout period for running the command on the ECS instance.
    Type: Number
    Default: 600
  regionId:
    Label:
      en: RegionId
      zh-cn: The region ID.
    Description:
      en: The ID of the region. Use the default value ${regionId} provided by Auto Scaling.
      zh-cn: The ID of the region. Use the default value ${regionId} provided by Auto Scaling.
    Type: String
    Default: '${regionId}'
  instanceIds:
    Label:
      en: InstanceIds
      zh-cn: A list of ECS instance IDs.
    Description:
      en: A list of ECS instance IDs. Use the default value ["${instanceId}"] provided by Auto Scaling.
      zh-cn: A list of ECS instance IDs. Use the default value ["${instanceId}"] provided by Auto Scaling.
    Type: List
    Default:
      - '${instanceIds}'
  lifecycleHookId:
    Label:
      en: LifecycleHookId
      zh-cn: The ID of the lifecycle hook.
    Description:
      en: The ID of the lifecycle hook. Use the default value ${lifecycleHookId} provided by Auto Scaling.
      zh-cn: The ID of the lifecycle hook. Use the default value ${lifecycleHookId} provided by Auto Scaling.
    Type: String
    Default: '${lifecycleHookId}'
  lifecycleActionToken:
    Label:
      en: LifecycleActionToken
      zh-cn: The token for the scaling activity that is associated with the instance.
    Description:
      en: The token for the scaling activity that is associated with the instance. Use the default value ${lifecycleActionToken} provided by Auto Scaling.
      zh-cn: The token for the scaling activity that is associated with the instance. Use the default value ${lifecycleActionToken} provided by Auto Scaling.
    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: The RAM role that OOS assumes.
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: downloadFileAndRunCommand
    OnError: CompleteLifecycleActionForAbandon
    OnSuccess: CompleteLifecycleActionForContinue
    Action: ACS::ECS::DownloadOSSFileAndRunCommand
    Description:
      en: Downloads a file to the ECS instances and runs a command.
      zh-cn: Downloads a file to the ECS instances and runs a command.
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      bucketName: '{{ bucketName }}'
      objectName: '{{ objectName }}'
      URLExpirationTime: '{{ URLExpirationTime }}'
      OSSRegion: '{{ OSSRegion }}'
      destinationDir: '{{ destinationDir }}'
      whetherSaveToFile: '{{ whetherSaveToFile }}'
      commandContent: '{{ commandContent }}'
      timeout: '{{ timeout }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ instanceIds }}'
  - Name: CompleteLifecycleActionForContinue
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Changes the lifecycle action to Continue.
      zh-cn: Changes the lifecycle action 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: Changes the lifecycle action to Abandon.
      zh-cn: Changes the lifecycle action to Abandon.
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: ABANDON