ALIYUN::ECS::Command creates 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,
"Launcher": String
"ResourceGroupId": String,
"ContentEncoding": String
}
}
Properties
|
Property |
Type |
Required |
Editable |
Description |
Constraint |
|
Name |
String |
No |
Yes |
The command name. |
1 to 128 characters. All character sets are supported. |
|
WorkingDir |
String |
No |
Yes |
The working directory of the command on the ECS instance. |
Defaults:
Note
If you set a non-default value, ensure the directory exists on the instance. |
|
CommandContent |
String |
No |
No |
The Base64-encoded content of the command. |
|
|
Launcher |
String |
No |
No |
The launcher for the script execution. |
The value can be up to 1 KB in size. |
|
Timeout |
Integer |
No |
Yes |
The command execution timeout on the ECS instance. |
When a command exceeds this period, Cloud Assistant Agent terminates the process by canceling its PID. Default value: 60. Unit: seconds. |
|
Type |
String |
Yes |
No |
The command type. |
Valid values:
|
|
Description |
String |
No |
Yes |
The command description. |
1 to 512 characters. All character sets are supported. |
|
EnableParameter |
Boolean |
No |
No |
Whether to use custom parameters in the command. |
Valid values:
|
|
Tags |
List |
No |
No |
The tags. Maximum: 20. |
For more information, see Tags properties. |
|
ContentEncoding |
String |
No |
No |
The command content encoding mode. |
Valid values:
Note
Invalid values default to Base64. |
|
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"
]
}
}
}
}