O recurso ALIYUN::SWAS::RunCommand executa comandos em instâncias do Simple Application Server.
Sintaxe
{
"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
}
}
Propriedades
Nome da propriedade | Tipo | Obrigatório | Atualizável | Descrição | Restrições |
CommandContent | String | Sim | Sim | Conteúdo do comando. | Observe o seguinte:
|
InstanceId | String | Sim | Não | ID da instância do Simple Application Server. | Nenhuma |
Name | String | Sim | Sim | Nome do comando a executar. | Nenhuma |
Type | String | Sim | Sim | Linguagem do comando. | Valores válidos:
|
ContentEncoding | String | Não | Sim | Modo de codificação do conteúdo do comando. | Valores válidos: PlainText: transmite o conteúdo do comando como texto simples, sem codificação. (Valor padrão) Base64: aplica codificação Base64. |
EnableParameter | Boolean | Não | Sim | Indica se o comando contém parâmetros personalizados. | Valor padrão: false. |
Parameters | Map | Não | Sim | Se o comando contiver parâmetros personalizados, especifique os pares chave-valor correspondentes durante a execução. | Por exemplo, se o conteúdo do comando for A quantidade de parâmetros personalizados varia de 0 a 20. Observe o seguinte:
O valor padrão é vazio. Isso cancela a configuração deste parâmetro e desativa os parâmetros personalizados. |
Sync | Boolean | Não | Não | Indica se a execução do comando ocorre de forma síncrona. | Nenhuma |
Timeout | Integer | Não | Sim | Define o tempo limite para execução do comando na instância do servidor. | Unidade: segundos. Se a execução do comando atingir o tempo limite, o Command Assistant interrompe forçadamente o processo da tarefa. Configure o tempo limite entre 10 e 86400 segundos (24 horas). Valor padrão: 60. |
WorkingDir | String | Não | Sim | Personaliza o caminho de execução do comando. | Caminhos padrão:
|
WorkingUser | String | Não | Sim | Especifique um usuário existente na instância do Simple Application Server para executar o comando. | Use um usuário comum para executar comandos e reduzir riscos de segurança. Valores padrão:
|
WindowsPasswordName | String | Não | Não | Nome da senha do usuário que executa o comando em uma instância Windows. | Para executar comandos como um usuário não padrão (System) em uma instância Windows, passe tanto |
Valores de retorno
Fn::GetAtt
InvokeResult: resultado da execução do comando.
InvokeId: ID da execução do comando.
Exemplos
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"
]
}
}
}
}