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

Syntax

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

Properties

Property Type Required Editable Description Constraint
Name String No Yes The name of the command. The name must be 1 to 128 characters in length. All character sets are supported.
WorkingDir String No Yes The 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\.
CommandContent String No No The 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.
Timeout Integer No Yes The 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.
Type String Yes No The 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.
Description String No Yes The description of the command. The description must be 1 to 512 characters in length. All character sets are supported.
EnableParameter Boolean No No Specifies whether to use custom parameters in the command. Default value: false. Valid values:
  • true
  • false

Return values

Fn::GetAtt

CommandId: the ID of the command.

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

Examples

  • JSON format

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "WorkingDir": {
          "Type": "String",
          "Description": "The path where command will be executed in the instance."
        },
        "CommandContent": {
          "Type": "String",
          "Description": "The content of command. Content requires base64 encoding. Maximum size support 16KB."
        },
        "Type": {
          "Type": "String",
          "Description": "The type of command."
        },
        "Description": {
          "Type": "String",
          "Description": "The description of command."
        },
        "Timeout": {
          "Type": "Number",
          "Description": "Total timeout when the command is executed in the instance. Input the time unit as second. Default is 60s."
        },
        "EnableParameter": {
          "Type": "Boolean",
          "Description": "Specifies whether the script contains custom parameters.\nDefault value: false",
          "AllowedValues": [
            true,
            false
          ]
        },
        "Name": {
          "Type": "String",
          "Description": "The name of command."
        }
      },
      "Resources": {
        "Command": {
          "Type": "ALIYUN::ECS::Command",
          "Properties": {
            "WorkingDir": {
              "Ref": "WorkingDir"
            },
            "CommandContent": {
              "Ref": "CommandContent"
            },
            "Type": {
              "Ref": "Type"
            },
            "Description": {
              "Ref": "Description"
            },
            "Timeout": {
              "Ref": "Timeout"
            },
            "EnableParameter": {
              "Ref": "EnableParameter"
            },
            "Name": {
              "Ref": "Name"
            }
          }
        }
      },
      "Outputs": {
        "CommandId": {
          "Description": "The id of command created.",
          "Value": {
            "Fn::GetAtt": [
              "Command",
              "CommandId"
            ]
          }
        }
      }
    }
  • YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      WorkingDir:
        Type: String
        Description: The path where command will be executed in the instance.
      CommandContent:
        Type: String
        Description: >-
          The content of command. Content requires base64 encoding. Maximum size
          support 16KB.
      Type:
        Type: String
        Description: The type of command.
      Description:
        Type: String
        Description: The description of command.
      Timeout:
        Type: Number
        Description: >-
          Total timeout when the command is executed in the instance. Input the time
          unit as second. Default is 60s.
      EnableParameter:
        Type: Boolean
        Description: |-
          Specifies whether the script contains custom parameters.
          Default value: false
        AllowedValues:
          - true
          - false
      Name:
        Type: String
        Description: The name of command.
    Resources:
      Command:
        Type: 'ALIYUN::ECS::Command'
        Properties:
          WorkingDir:
            Ref: WorkingDir
          CommandContent:
            Ref: CommandContent
          Type:
            Ref: Type
          Description:
            Ref: Description
          Timeout:
            Ref: Timeout
          EnableParameter:
            Ref: EnableParameter
          Name:
            Ref: Name
    Outputs:
      CommandId:
        Description: The id of command created.
        Value:
          'Fn::GetAtt':
            - Command
            - CommandId