ALIYUN::ECS::Command类型用于新建云助手命令。
语法
{
"Type": "ALIYUN::ECS::Command",
"Properties": {
"Name": String,
"WorkingDir": String,
"CommandContent": String,
"Timeout": Integer,
"Type": String,
"Description": String,
"EnableParameter": Boolean
}
}
属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Name | String | 否 | 是 | 命令名称。 | 长度为1~128个字符。支持全字符集。 |
WorkingDir | String | 否 | 是 | 您创建的命令在ECS实例中运行的目录。 | 默认值:
|
CommandContent | String | 否 | 否 | 命令Base64编码后的内容。 | 该参数的值必须使用Base64编码后传输,且脚本内容的大小在Base64编码之后不能超过16KB。
命令内容支持使用自定义参数形式,具体通过指定参数
EnableParameter=true 启用自定义参数功能:
|
Timeout | Integer | 否 | 是 | 您创建的命令在ECS实例中执行时的超时时间。 |
当因为某种原因无法运行您创建的命令时,会出现超时现象;超时后,会强制终止命令进程,即取消命令的 PID。 默认值:60 单位:秒。 |
Type | String | 是 | 否 | 命令的类型。 | 取值:
|
Description | String | 否 | 是 | 命令描述。 | 长度为1~512个字符。支持全字符集。 |
EnableParameter | Boolean | 否 | 否 | 创建的命令是否使用自定义参数。 | 取值
|
返回值
Fn::GetAtt
CommandId:命令ID。
示例
JSON
格式
{
"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
格式
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