All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand

Last Updated:Jun 04, 2026

Uses an Auto Scaling lifecycle hook to download an OSS file to ECS instances and run commands.

Template name

ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand — Downloads an OSS file to an ECS instance and runs a command through a lifecycle hook.

Execute Now

Template description

Downloads an Object Storage Service (OSS) object to Elastic Compute Service (ECS) instances through a lifecycle hook and runs commands on them.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

bucketName

OSS bucket name.

String

Yes

objectName

OSS object name.

String

Yes

destinationDir

Target directory on the instance.

String

Yes

URLExpirationTime

Validity period of the OSS object download URL.

Number

No

6000

OSSRegion

Region of the OSS bucket.

String

No

{{ ACS::RegionId }}

whetherSaveToFile

Whether to save content to a local file.

Boolean

No

True

commandContent

Cloud Assistant commands to run on the instance.

String

No

echo hello

timeout

Timeout for command execution, in seconds.

Number

No

600

regionId

The region ID.

String

No

${regionId}

instanceIds

ECS instance IDs.

List

No

['${instanceIds}']

lifecycleHookId

The lifecycle hook ID.

String

No

${lifecycleHookId}

lifecycleActionToken

Token for the scaling activity associated with the instances.

String

No

${lifecycleActionToken}

rateControl

Rate control settings.

Json

No

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

RAM role assumed by OOS.

String

No

OOSServiceRole

Output parameters

None

Required permissions

{
    "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"
        }
    ]
}

Details

ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand

Template content

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