All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-RunRemoteShellScript

Last Updated:Jun 22, 2026

Template name

ACS-ECS-RunRemoteShellScript: Downloads a shell script from OSS to an ECS instance and runs it

Execute now

Template description

Downloads a shell script from Object Storage Service (OSS) to an ECS instance and runs it by using Cloud Assistant.

Template type

Automation

Owner

Alibaba Cloud

Input parameters

Parameter name

Description

Type

Required

Default value

Constraints

instanceId

The ID of the ECS instance on which to run the script.

String

Yes

instanceRole

The RAM role attached to the instance.

String

Yes

fileName

The name of the shell script file to run.

String

Yes

srcUrl

The OSS directory where the script file is stored.

String

Yes

destUrl

The destination directory on the ECS instance to which the script file is copied.

String

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

workingDir

The working directory on the instance in which the command runs.

String

No

/root

timeout

The maximum timeout period for running the command. Unit: seconds.

Number

No

600

OOSAssumeRole

The RAM role that OOS assumes to run this template.

String

No

“”

Output parameters

Parameter name

Description

Type

commandOutput

String

Access policy required for this template

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

Details

ACS-ECS-RunRemoteShellScript details

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Runs a remote shell script.
  zh-cn: Runs a remote shell script.
  name-en: ACS-ECS-RunRemoteShellScript
  name-zh-cn: Run a remote shell script
  categories:
    - run_command
Parameters:
  regionId:
    Label:
      en: Region ID
      zh-cn: Region ID
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  instanceId:
    Label:
      en: ECS Instance
      zh-cn: ECS Instance
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    AssociationPropertyMetadata:
      RegionId: regionId
  instanceRole:
    Label:
      en: The RAM role attached to the instance
      zh-cn: The RAM role attached to the instance
    Type: String
  fileName:
    Label:
      en: The name of the file to execute
      zh-cn: The name of the file to execute
    Type: String
  srcUrl:
    Label:
      en: The directory in OSS where the file is located
      zh-cn: The directory in OSS where the file is located
    Type: String
  destUrl:
    Label:
      en: The directory on the ECS instance to which the file is copied
      zh-cn: The directory on the ECS instance to which the file is copied
    Type: String
  workingDir:
    Label:
      en: The directory on the instance where the command runs
      zh-cn: The directory on the instance where the command runs
    Type: String
    Default: /root
  timeout:
    Label:
      en: The maximum timeout period for running the command
      zh-cn: The maximum timeout period for running the command
    Type: Number
    Default: 600
  OOSAssumeRole:
    Label:
      en: The RAM role that OOS assumes
      zh-cn: The RAM role that OOS assumes
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: copyOSSFileToInstance
    Description:
      en: Copies a file from OSS to a Linux instance.
      zh-cn: Copies a file from OSS to a Linux instance.
    Action: 'ACS::ECS::CopyLinuxInstanceFileFromOSS'
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ instanceId }}'
      instanceRole: '{{ instanceRole }}'
      srcUrl: '{{ srcUrl }}/{{ fileName }}'
      destUrl: '{{ destUrl }}'
  - Name: runCommand
    Description:
      en: Executes a Cloud Assistant command.
      zh-cn: Executes a Cloud Assistant command.
    Action: 'ACS::ECS::RunCommand'
    Properties:
      regionId: '{{ regionId }}'
      commandContent: '/bin/bash {{ destUrl }}/{{ fileName }}'
      instanceId: '{{ instanceId }}'
      commandType: RunShellScript
      workingDir: '{{ workingDir }}'
      timeout: '{{ timeout }}'
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
Outputs:
  commandOutput:
    Type: String
    Value: '{{ runCommand.commandOutput }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - instanceRole
          - fileName
          - srcUrl
          - destUrl
          - workingDir
          - timeout
        Label:
          default:
            zh-cn: Run Shell Script Options
            en: Run Shell Script Options
      - Parameters:
          - instanceId
        Label:
          default:
            zh-cn: Select ECS Instance
            en: Select ECS Instance
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Control Options
            en: Control Options