All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-BulkyRunCommandAcrossRegions

Last Updated:Nov 25, 2024

Template name

ACS-ECS-BulkyRunCommandAcrossRegions

Execute Now

Template description

Runs a Cloud Assistant command on multiple Elastic Compute Service (ECS) instances across regions at a time.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

instanceInfos

The information about the ECS instances.

List

No

[]

commandType

The type of the Cloud Assistant command.

String

No

RunShellScript

commandContent

The Cloud Assistant command to be run on the ECS instances.

String

No

echo hello

timeout

The timeout period for running the command on the ECS instances.

Number

No

600

rateControl

The rate control settings.

Json

No

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

OOSAssumeRole

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

String

No

""

Output parameters

Parameter

Description

Type

commandOutputs

List

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-BulkyRunCommandAcrossRegions.yml at GitHub.

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Bulky run command on ECS instances across multiple regions
  zh-cn: the description in Chinese
  name-en: ACS-ECS-BulkyRunCommandAcrossRegions
  name-zh-cn: the description in Chinese
  categories:
    - run_command
Parameters:
  instanceInfos:
    Description:
      en: 'Format: {"regionId": "cn-xxx", "instanceId": "i-xxx"}'
      zh-cn: the description in Chinese
    Label:
      en: InstanceInfos
      zh-cn: the description in Chinese
    Type: List
    Default: []
  commandType:
    Label:
      en: CommandType
      zh-cn: the description in Chinese
    Type: String
    AllowedValues:
      - RunBatScript
      - RunPowerShellScript
      - RunShellScript
    Default: RunShellScript
  commandContent:
    Label:
      en: CommandContent
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: Code
    Default: echo hello
  timeout:
    Label:
      en: Timeout
      zh-cn: the description in Chinese
    Type: Number
    Default: 600
  rateControl:
    Label:
      en: RateControl
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: runCommand
    Action: ACS::ECS::RunCommand
    Description:
      en: Execute cloud assistant command
      zh-cn: the description in Chinese
    Properties:
      regionId:
        'Fn::Select':
          - regionId
          - '{{ ACS::TaskLoopItem }}'
      instanceId:
        'Fn::Select':
          - instanceId
          - '{{ ACS::TaskLoopItem }}'
      commandContent: '{{ commandContent }}'
      commandType: '{{ commandType }}'
      timeout: '{{ timeout }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ instanceInfos }}'
      Outputs:
        commandOutputs:
          AggregateType: Fn::ListJoin
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
Outputs:
  commandOutputs:
    Type: List
    Value: '{{ runCommand.commandOutputs }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - instanceInfos
          - commandType
          - commandContent
          - timeout
        Label:
          default:
            zh-cn: the description in Chinese
            en: Configure Parameters
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options