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,
"Tags": List,
"ResourceGroupId": String,
"ContentEncoding": String
}
}
Properties
Property | Type | Required | Editable | Description | Constraint |
Name | String | No | Yes | The command name. | The command name must be 1 to 128 characters in length. All character sets are supported. |
WorkingDir | String | No | Yes | The working directory of the command on the Elastic Compute Service (ECS) instance. | Default values:
Note If you set WorkingDir to a value other than default ones, make sure that the directory exists on the instance. |
CommandContent | String | No | No | The Base64-encoded content of the command. |
|
Timeout | Integer | No | Yes | The timeout period for running the command on the ECS instance. | If the command fails to run within the specified period, the command times out. When a command execution times out, Cloud Assistant Agent forcefully terminates the command process by canceling the process ID (PID). Default value: 60. Unit: seconds. |
Type | String | Yes | No | The command type. | Valid values:
|
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. | Valid values:
|
Tags | List | No | No | The tags. You can add up to 20 tags. | For more information, see Tags properties. |
ContentEncoding | String | No | No | The encoding mode of the command content. | Valid values:
Note If you specify an invalid value, Base64 is used for this property. |
ResourceGroupId | String | No | Yes | The ID of the resource group to which the command belongs. | None. |
Tags syntax
"Tags": [
{
"Key": String,
"Value": String
}
]
Tags properties
Property | Type | Required | Editable | Description | Constraint |
Key | String | Yes | No | The tag key. | The tag key must be 1 to 128 characters in length, and cannot contain |
Value | String | No | No | The tag value. | The tag value can be up to 128 characters in length, and cannot contain |
Return values
Fn::GetAtt
CommandId: the command ID.
You can run the command only once. For more information, see ALIYUN::ECS::RunCommand.
Examples
YAML
format
ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
Command:
Type: ALIYUN::ECS::Command
Properties:
CommandContent:
Fn::Base64Encode: |
#!/bin/bash
echo "hello" >> /root/test.sh
Type: RunShellScript
Name:
Ref: ALIYUN::StackName
Outputs:
CommandId:
Description: The id of command created.
Value:
Fn::GetAtt:
- Command
- CommandId
JSON
format
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
},
"Resources": {
"Command": {
"Type": "ALIYUN::ECS::Command",
"Properties": {
"CommandContent": {
"Fn::Base64Encode": "#!/bin/bash\necho \"hello\" >> /root/test.sh\n"
},
"Type": "RunShellScript",
"Name": {
"Ref": "ALIYUN::StackName"
}
}
}
},
"Outputs": {
"CommandId": {
"Description": "The id of command created.",
"Value": {
"Fn::GetAtt": [
"Command",
"CommandId"
]
}
}
}
}