All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-RunRemoteShellScript

Last Updated:Nov 25, 2024

Template name

ACS-ECS-RunRemoteShellScript

Execute Now

Template description

Runs a remote Shell script on an Elastic Compute Service (ECS) instance.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

instanceId

The ID of the ECS instance.

String

Yes

instanceRole

The Resource Access Management (RAM) role that is attached to the ECS instance.

String

Yes

fileName

The name of the script file to be executed.

String

Yes

srcUrl

The directory in which the script file is stored in Object Storage Service (OSS).

String

Yes

destUrl

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

String

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

workingDir

The directory in which the command is run in the ECS instance.

String

No

/root

timeout

The maximum timeout period for running the command.

Number

No

600

OOSAssumeRole

The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS).

String

No

""

Output parameters

Parameter

Description

Type

commandOutput

String

Permission policy that is required to execute the template

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

References

For more information, see ACS-ECS-RunRemoteShellScript.yml at GitHub.

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Run remote shell script
  zh-cn: the description in Chinese
  name-en: ACS-ECS-RunRemoteShellScript
  name-zh-cn: the description in Chinese
  categories:
    - run_command
Parameters:
  regionId:
    Label:
      en: RegionId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  instanceId:
    Label:
      en: InstanceId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    AssociationPropertyMetadata:
      RegionId: regionId
  instanceRole:
    Label:
      en: InstanceRole
      zh-cn: the description in Chinese
    Type: String
  fileName:
    Label:
      en: FileName
      zh-cn: the description in Chinese
    Type: String
  srcUrl:
    Label:
      en: SrcUrl
      zh-cn: the description in Chinese
    Type: String
  destUrl:
    Label:
      en: DestUrl
      zh-cn: the description in Chinese
    Type: String
  workingDir:
    Label:
      en: WorkingDir
      zh-cn: the description in Chinese
    Type: String
    Default: /root
  timeout:
    Label:
      en: Timeout
      zh-cn: the description in Chinese
    Type: Number
    Default: 600
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: copyOSSFileToInstance
    Description:
      en: Copies OSS file to linux instace
      zh-cn: the description in Chinese
    Action: 'ACS::ECS::CopyLinuxInstanceFileFromOSS'
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ instanceId }}'
      instanceRole: '{{ instanceRole }}'
      srcUrl: '{{ srcUrl }}/{{ fileName }}'
      destUrl: '{{ destUrl }}'
  - Name: runCommand
    Description:
      en: Execute cloud assistant command
      zh-cn: the description in Chinese
    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: the description in Chinese
            en: Run Shell Script Options
      - Parameters:
          - instanceId
        Label:
          default:
            zh-cn: the description in Chinese
            en: Select ECS Instance
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options