All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-RunShellScript

Last Updated:Nov 25, 2024

Template name

ACS-ECS-RunShellScript

Execute Now

Template description

Runs a 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

commandContent

The Cloud Assistant command.

String

Yes

workingDir

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

String

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

timeout

The maximum timeout period. Unit: seconds.

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:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

References

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

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Run shell script.
  zh-cn: the description in Chinese
  title: ACS-ECS-RunShellScript
  name-zh-cn: the description in Chinese
  categories:
    - run_command
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: the description in Chinese
    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
  commandContent:
    Label:
      en: CommandContent
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: Code
  workingDir:
    Label:
      en: WorkingDir
      zh-cn: the description in Chinese
    Type: String
  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: runCommand
  Description:
    en: Execute cloud assistant command
    zh-cn: the description in Chinese
  Action: ACS::ECS::RunCommand
  Properties:
    regionId: '{{ regionId }}'
    commandContent: "{{ commandContent }}"
    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:
          - commandContent
          - workingDir
          - timeout
        Label:
          default:
            zh-cn: the description in Chinese
            en: run command options
      - Parameters:
          - regionId
          - instanceId
        Label:
          default:
            zh-cn: the description in Chinese
            en: Select Ecs Instances
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options