Template name
ACS-ECS-BulkyRunCommand: Send remote commands
Template description
Run Cloud Assistant commands on multiple Elastic Compute Service (ECS) instances in batches. This template is designed for scenarios that require managing many ECS instances simultaneously, such as application management and resource tagging. When you configure the template, you must provide required parameters, including the region ID (`regionId`), the resource type (`resourceType`), and the target instances (`targets`). You also specify the command type (`commandType`), such as Shell or Python, and the command content (`commandContent`). After the template runs, it returns the output of the batch operation, which you can use to verify the command execution status.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
targets | Target instance | Json | Yes | ||
commandContent | The command content. | String | Yes | The command can be up to 16,384 bytes in length. | |
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
resourceType | The resource type. | String | No | ALIYUN::ECS::Instance | |
commandType | The command type. | String | No | RunShellScript | |
workingDir | The directory in which the command is run. | String | No | "" | |
timeout | The timeout period in seconds. | Number | No | 600 | |
enableParameter | Specifies whether the command contains encryption parameters or custom parameters. | Boolean | No | False | |
username | The username of the account that is used to run the command. | String | No | "" | |
windowsPasswordName | The password of the account that is used to run the command on the Windows instance. | String | No | "" | |
rateControl | Task execution concurrency | 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:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:DescribeManagedInstances",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
Details of ACS-ECS-BulkyRunCommand
Template content
FormatVersion: OOS-2019-06-01
Description:
en: 'Runs Cloud Assistant commands on multiple Elastic Compute Service (ECS) instances in batches. This template is for scenarios that require managing many ECS instances at once, such as for application management and resource tagging. When you configure the template, you must provide required parameters. These include the region ID (regionId), the resource type (resourceType), and the target instances (targets). You also specify the command type (commandType), such as Shell or Python, and the command content (commandContent). After the template runs, it returns the output of the batch operation. You can use the output to verify the command execution status.'
zh-cn: the description in Chinese
name-en: Run Command
name-zh-cn: the description in Chinese
categories:
- run_command
- application_manage
- computenest
- tag_operate_resource
Parameters:
regionId:
Type: String
Label:
en: Region ID
zh-cn: the description in Chinese
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
resourceType:
Type: String
Label:
en: Resource type
zh-cn: the description in Chinese
AssociationPropertyMetadata:
LocaleKey: TargetResourceType
AllowedValues:
- ALIYUN::ECS::Instance
- ALIYUN::ECS::ManagedInstance
Default: ALIYUN::ECS::Instance
targets:
Type: Json
Label:
en: Target instance
zh-cn: the description in Chinese
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: resourceType
RegionId: regionId
Status: Running
commandType:
Label:
en: Command type
zh-cn: the description in Chinese
AssociationPropertyMetadata:
LocaleKey: ECSCommandType
Type: String
AllowedValues:
- RunShellScript
- RunPythonScript
- RunPerlScript
- RunBatScript
- RunPowerShellScript
Default: RunShellScript
commandContent:
Label:
en: Command content
zh-cn: the description in Chinese
Type: String
MaxLength: 16384
AssociationProperty: ALIYUN::OOS::Command::CommandContent
AssociationPropertyMetadata:
CommandType: ${commandType}
workingDir:
Description:
en: 'For Linux instances, the default is the home directory of the administrator (root), which is /root. For Windows instances, the default is the directory where the Cloud Assistant client process is located, such as C:\Windows\System32. Ensure that the directory you enter is correct.'
zh-cn: the description in Chinese
Label:
en: Working directory
zh-cn: the description in Chinese
Type: String
Default: ''
AssociationPropertyMetadata:
Value:
- Condition:
Fn::Or:
- Fn::Equals:
- ${commandType}
- RunShellScript
- Fn::Equals:
- ${commandType}
- RunPythonScript
- Fn::Equals:
- ${commandType}
- RunPerlScript
Value: /root
- Condition:
Fn::Or:
- Fn::Equals:
- ${commandType}
- RunBatScript
- Fn::Equals:
- ${commandType}
- RunPowerShellScript
Value: C:\\Windows\\System32
timeout:
Label:
en: Timeout (s)
zh-cn: the description in Chinese
Type: Number
Default: 600
enableParameter:
Label:
en: Enable parameter
zh-cn: the description in Chinese
Type: Boolean
Default: false
username:
Description:
en: The username to run the command on the ECS instance. The username can be up to 255 characters long. For Linux instances, the command is run as the root user by default. For Windows instances, the command is run as the System user by default. Ensure that the username you enter is correct. <a href="https://www.alibabacloud.com/help/doc-detail/203771.html" target="_blank">Learn more</a>
zh-cn: the description in Chinese
Label:
en: Username
zh-cn: the description in Chinese
Type: String
Default: ''
windowsPasswordName:
Label:
en: Password name for Windows user
zh-cn: the description in Chinese
Type: String
Default: ''
AssociationProperty: ALIYUN::OOS::SecretParameter::Value
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Or:
- Fn::Equals:
- ${commandType}
- RunBatScript
- Fn::Equals:
- ${commandType}
- RunPowerShellScript
rateControl:
Label:
en: Rate control
zh-cn: the description in Chinese
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: RAM role assumed by OOS
zh-cn: the description in Chinese
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Gets ECS instances
zh-cn: the description in Chinese
Action: ACS::SelectTargets
Properties:
ResourceType: '{{ resourceType }}'
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
- Name: runCommand
Action: ACS::ECS::RunCommand
Description:
en: Runs the Cloud Assistant command
zh-cn: the description in Chinese
Properties:
regionId: '{{ regionId }}'
commandContent: '{{ commandContent }}'
instanceId: '{{ ACS::TaskLoopItem }}'
commandType: '{{ commandType }}'
workingDir: '{{ workingDir }}'
timeout: '{{ timeout }}'
enableParameter: '{{ enableParameter }}'
username: '{{ username }}'
windowsPasswordName: '{{ windowsPasswordName }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
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:
- commandType
- commandContent
- workingDir
- timeout
- enableParameter
- username
- windowsPasswordName
Label:
default:
zh-cn: the description in Chinese
en: Command execution options
- Parameters:
- regionId
- resourceType
- targets
Label:
default:
zh-cn: the description in Chinese
en: Select instances
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Advanced options