The ALIYUN::SWAS::RunCommand resource executes commands on Simple Application Server instances.
Syntax
{
"Type": "ALIYUN::SWAS::RunCommand",
"Properties": {
"CommandContent": String,
"InstanceId": String,
"Name": String,
"Type": String,
"ContentEncoding": String,
"EnableParameter": Boolean,
"Parameters": Map,
"Sync": Boolean,
"Timeout": Integer,
"WorkingDir": String,
"WorkingUser": String,
"WindowsPasswordName": String
}
}
Properties
|
Property Name |
Type |
Required |
Updatable |
Description |
Constraints |
|
CommandContent |
String |
Yes |
Yes |
The command content. |
Note the following:
|
|
InstanceId |
String |
Yes |
No |
The ID of the Simple Application Server instance. |
None |
|
Name |
String |
Yes |
Yes |
The name of the command to execute. |
None |
|
Type |
String |
Yes |
Yes |
The language type of the command. |
Valid values:
|
|
ContentEncoding |
String |
No |
Yes |
The encoding mode for the command content. |
Valid values: PlainText: The command content is not encoded and is transmitted as plaintext. (Default value) Base64: Base64 encoding is used. |
|
EnableParameter |
Boolean |
No |
Yes |
Indicates whether the command contains custom parameters. |
Default value: false. |
|
Parameters |
Map |
No |
Yes |
If the command contains custom parameters, specify the key-value pairs for these custom parameters when executing the command. |
For example, if the command content is The number of custom parameters ranges from 0 to 20. Note the following:
The default value is empty, which means canceling the setting of this parameter to disable custom parameters. |
|
Sync |
Boolean |
No |
No |
Indicates whether to run the command synchronously. |
None |
|
Timeout |
Integer |
No |
Yes |
Set the timeout for the command on the server instance. |
Unit: seconds. If the command execution times out, Command Assistant forcibly stops the task process. The timeout can be set from 10 to 86400 seconds (24 hours). Default value: 60. |
|
WorkingDir |
String |
No |
Yes |
Customize the execution path for the command. |
Default paths are as follows:
|
|
WorkingUser |
String |
No |
Yes |
Specify an existing user on the Simple Application Server instance to execute the command. |
Use a regular user to execute commands to reduce security risk. Default values:
|
|
WindowsPasswordName |
String |
No |
No |
The password name of the user who executes the command in a Windows instance. |
If you want to execute commands as a non-default user (System) in a Windows instance, pass both `WorkingUser` and this parameter. To reduce the risk of password leakage, store the plaintext password in the parameter repository of the O&M orchestration service. Only pass the password name here. |
Return Values
Fn::GetAtt
-
InvokeResult: The result of the command execution.
-
InvokeId: The command execution ID.
Examples
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
CommandContent:
AssociationProperty: TextArea
Type: String
Description:
en: The plaintext content of the command to run.
Required: true
Type:
Type: String
Description:
en: |-
The language type of the O&M script. Valid values:
RunShellScript: shell scripts for Linux instances
RunBatScript: batch scripts for Windows instances
RunPowerShellScript: PowerShell scripts for Windows instances
AllowedValues:
- RunShellScript
- RunBatScript
- RunPowerShellScript
Required: true
InstanceId:
Type: String
Description:
en: The ID of the SWAS instance on which to run the command. The instance must be in 'Running' status.
Required: true
Name:
Type: String
Description:
en: The name of the command to run.
Required: true
Resources:
RunCommand:
Type: ALIYUN::SWAS::RunCommand
Properties:
CommandContent:
Ref: CommandContent
Type:
Ref: Type
InstanceId:
Ref: InstanceId
Name:
Ref: Name
Outputs:
InvokeResult:
Description: The result of the command execution.
Value:
Fn::GetAtt:
- RunCommand
- InvokeResult
InvokeId:
Description: The ID of the command execution.
Value:
Fn::GetAtt:
- RunCommand
- InvokeId
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"CommandContent": {
"AssociationProperty": "TextArea",
"Type": "String",
"Description": {
"en": "The plaintext content of the command to run."
},
"Required": true
},
"Type": {
"Type": "String",
"Description": {
"en": "The language type of the O&M script. Valid values:\nRunShellScript: shell scripts for Linux instances\nRunBatScript: batch scripts for Windows instances\nRunPowerShellScript: PowerShell scripts for Windows instances"
},
"AllowedValues": [
"RunShellScript",
"RunBatScript",
"RunPowerShellScript"
],
"Required": true
},
"InstanceId": {
"Type": "String",
"Description": {
"en": "The ID of the SWAS instance on which to run the command. The instance must be in 'Running' status."
},
"Required": true
},
"Name": {
"Type": "String",
"Description": {
"en": "The name of the command to run."
},
"Required": true
}
},
"Resources": {
"RunCommand": {
"Type": "ALIYUN::SWAS::RunCommand",
"Properties": {
"CommandContent": {
"Ref": "CommandContent"
},
"Type": {
"Ref": "Type"
},
"InstanceId": {
"Ref": "InstanceId"
},
"Name": {
"Ref": "Name"
}
}
}
},
"Outputs": {
"InvokeResult": {
"Description": "The result of the command execution.",
"Value": {
"Fn::GetAtt": [
"RunCommand",
"InvokeResult"
]
}
},
"InvokeId": {
"Description": "The ID of the command execution.",
"Value": {
"Fn::GetAtt": [
"RunCommand",
"InvokeId"
]
}
}
}
}