ALIYUN::ECS::Command is used to create a Cloud Assistant command.


  "Type": "ALIYUN::ECS::Command",
  "Properties": {
    "Name": String,
    "WorkingDir": String,
    "CommandContent": String,
    "Timeout": Integer,
    "Type": String,
    "Description": String,
    "EnableParameter": Boolean


NameStringNoYesThe name of the command. The name must be 1 to 128 characters in length. All character sets are supported.
WorkingDirStringNoYesThe execution path of the command in the Elastic Compute Service (ECS) instance.
  • For Linux instances, the default value is /root, which is the home directory of the root user.
  • For Windows instances, the default value is the directory where the Cloud Assistant client process resides, such as C:\Windows\System32\.
CommandContentStringNoNoThe Base64-encoded content of the command. The value of this property must be Base64-encoded and cannot exceed 16 KB in size.
The command content supports custom parameters. To enable custom parameters, set the EnableParameter property to true.
  • You can define custom parameters by enclosing them in two nested braces ({{}}). The spaces and line feeds before and after parameter names in {{}} are ignored.
  • You can specify up to 20 custom parameters.
  • The name of a custom parameter can contain letters and digits. The name is not case-sensitive.
  • The name of each custom parameter cannot exceed 64 characters in length.
TimeoutIntegerNoYesThe timeout period that is specified for the command to run on the ECS instance.

If the command fails to run within the specified period due to specific reasons, the command execution times out. In this case, the command process is forcefully terminated by canceling the process ID (PID) of the command.

Default value: 60.

Unit: seconds.
TypeStringYesNoThe type of the command. Valid values:
  • RunBatScript: batch command. Batch commands are applicable to Windows instances.
  • RunPowerShellScript: PowerShell command. PowerShell commands are applicable to Windows instances.
  • RunShellScript: shell command. Shell commands are applicable to Linux instances.
DescriptionStringNoYesThe description of the command. The description must be 1 to 512 characters in length. All character sets are supported.
EnableParameterBooleanNoNoSpecifies whether to use custom parameters in the command. Default value: false. Valid values:
  • true
  • false

Return values


CommandId: the ID of the command.

Note For more information about how to run the command, see ALIYUN::ECS::RunCommand.


  • YAMLformat

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters: {}
        Type: ALIYUN::ECS::Command
            Fn::Base64Encode: |
              echo "hello" >> /root/
          Type: RunShellScript
            Ref: ALIYUN::StackName
        Description: The id of command created.
            - Command
            - CommandId
  • JSONformat

      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
      "Resources": {
        "Command": {
          "Type": "ALIYUN::ECS::Command",
          "Properties": {
            "CommandContent": {
              "Fn::Base64Encode": "#!/bin/bash\necho \"hello\" >> /root/\n"
            "Type": "RunShellScript",
            "Name": {
              "Ref": "ALIYUN::StackName"
      "Outputs": {
        "CommandId": {
          "Description": "The id of command created.",
          "Value": {
            "Fn::GetAtt": [