指定 CommandId、InstanceId、ResourceGroupId 等參數,為一台或多台 ECS 執行個體觸發一條雲端助手命令。
介面說明
介面說明。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
ecs:InvokeCommand |
update |
*Command
*Instance
|
|
無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| RegionId |
string |
是 |
地域 ID。您可以呼叫 DescribeRegions 查看最新的阿里雲地域清單。 |
cn-hangzhou |
| ResourceGroupId |
string |
否 |
命令執行的資源群組 ID,當指定該參數時: |
rg-bp67acfmxazb4p**** |
| CommandId |
string |
是 |
命令 ID。您可以透過介面 DescribeCommands 查詢所有可用的 CommandId。 |
c-e996287206324975b5fbe1d**** |
| RepeatMode |
string |
否 |
設定命令執行的方式。取值範圍: |
Once |
| Timed |
boolean |
否 |
說明
該參數已廢棄,傳入該參數不會生效。 |
true |
| Frequency |
string |
否 |
定時執行命令的執行時間。目前支援三種定時執行方式:固定時間間隔執行(基於 Rate 運算式)、僅在指定時間執行一次、基於時鐘定時執行(基於 Cron 運算式)。 |
0 */20 * * * ? |
| Parameters |
object |
否 |
啟用自訂參數功能時,執行命令時傳入的自訂參數的鍵值對。自訂參數的個數範圍為 0~10。 |
{"name":"Jack", "accessKey":"LTAI************"} |
| Username |
string |
否 |
在 ECS 執行個體中執行命令的使用者名稱。長度不得超過 255 個字元。 |
test |
| WindowsPasswordName |
string |
否 |
在 Windows 執行個體中執行命令的使用者的密碼名稱。長度不得超過 255 個字元。 |
axtSecretPassword |
| InstanceId |
array |
否 |
需要執行命令的執行個體清單,最多能指定 100 台執行個體 ID。N 的取值範圍為 1~100。 |
i-bp185dy2o3o6n**** |
|
string |
否 |
需要執行命令的執行個體 ID。 |
i-bp185dy2o3o6n**** |
|
| ContainerId |
string |
否 |
容器 ID。僅支援 64 位元 16 進位字串。支援使用 |
ab141ddfbacfe02d9dbc25966ed971536124527097398d419a6746873fea**** |
| ContainerName |
string |
否 |
容器名稱。 |
test-container |
| Timeout |
integer |
否 |
執行命令的逾時時間,單位:秒。 |
60 |
| Tag |
array<object> |
否 |
標籤清單。 |
|
|
object |
否 |
標籤清單。 |
||
| Value |
string |
否 |
命令執行的標籤值。N 的取值範圍為 1~20。該值可以為空字串。 |
TestValue |
| Key |
string |
否 |
命令執行的標籤鍵。N 的取值範圍為 1~20。一旦傳入該值,則不允許為空字串。 |
TestKey |
| ClientToken |
string |
否 |
保證請求冪等性。從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元,且不能超過 64 個字元。更多詳情,請參見如何保證冪等性。 |
123e4567-e89b-12d3-a456-42665544**** |
| ResourceTag |
array<object> |
否 |
用於篩選執行個體的標籤清單。可以在不指定 InstanceId 的情況下,向具有相同標籤的執行個體批次執行命令。 |
|
|
object |
否 |
用於篩選執行個體的標籤。可以在不指定 InstanceId 的情況下,向具有相同標籤的執行個體批次執行命令。 |
||
| Value |
string |
否 |
用於篩選執行個體的標籤值。 |
TestValue |
| Key |
string |
否 |
用於篩選執行個體的標籤鍵。 |
TestKey |
| TerminationMode |
string |
否 |
停止任務(手動停止或執行逾時中斷)時的模式。可能值: |
ProcessTree |
| Launcher |
string |
否 |
指令碼執行的引導程式。長度不能超過 1 KB。 |
python3 -u {{ACS::ScriptFileName|Ext(".py")}} |
| WorkingDir |
string |
否 |
命令在 ECS 執行個體中執行的目錄。長度不得超過 200 個字元。 |
/home/user |
| OssOutputDelivery |
string |
否 |
命令執行 Output OSS 投遞設定。 |
oss://testBucket/testPrefix |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
|||
| InvokeId |
string |
命令執行 ID。 |
t-7d2a745b412b4601b2d47f6a768d**** |
| RequestId |
string |
請求 ID。 |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
樣本
正常返回樣本
JSON格式
{
"InvokeId": "t-7d2a745b412b4601b2d47f6a768d****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | ResourceBusy.SlrCreation | The ServiceLinkedRole is still being created or has not taken effect yet. Please try again later. | |
| 400 | RegionId.ApiNotSupported | The api is not supported in this region. | 本地域暫不支援該 API。 |
| 400 | InvalidParameter.WorkingDir | The specified parameter WorkingDir is not valid. | 指定的參數 WorkingDir 不合法。 |
| 400 | MissingParam.InstanceId | The parameter instanceId is missing or empty. | 執行個體 ID 為空。 |
| 400 | InvalidContainerId.Malformed | The specified parameter ContainerId is not valid. | 指定的容器 ID 不合法。 |
| 400 | InvalidContainerName.Malformed | The specified parameter ContainerName is not valid. | 指定的容器名稱不合法。 |
| 400 | InvalidClientToken.Malformed | The specified parameter clientToken is not valid. | 指定的參數 ClientToken 格式不符合規範要求,該參數應該只包括 ASCII 字元,且長度不應該超過 64 個字元。 |
| 400 | InvalidInstance.NotMatch | The specified instance type does not match the command. | |
| 400 | MissingParam.Frequency | The frequency must be specified when you create a timed task. | |
| 400 | InvalidParam.Frequency | The specified frequency is invalid. | |
| 400 | Parameter.MissingValue | The parameter value of this command is required. | |
| 400 | Parameter.Disabled | Parameters cannot be passed in when the command customization function is disabled. | |
| 400 | InvalidParameter.Parameters | The specified parameter Parameters is not valid. | 指定的參數 Parameters 不合法。 |
| 400 | NumberExceed.ResourceTags | The maximum number of ResourceTags is exceeded. | |
| 400 | MissingParameter.ResourceTagKey | You must specify ResourceTag.N.Key. | |
| 400 | InvalidResourceTagKey.Malformed | The specified ResourceTag key is not valid. | |
| 400 | InvalidResourceTagValue.Malformed | The specified ResourceTag value is not valid. | |
| 400 | Duplicate.ResourceTagKey | The ResourceTag contains duplicate keys. | |
| 400 | InvalidResourceTag.InstanceNotFound | InstanceIds are not found by the specified ResourceTag. | |
| 400 | InvalidResourceTag.ConflictWithInstanceIds | The specified param ResourceTag conflicts with InstanceId. | |
| 400 | InvalidOssOutputDelivery.BucketInOtherRegion | The OSS bucket specified in the parameter OssOutputDelivery is in another region. | 參數 OssOutputDelivery 中指定的 OSS bucket 在其他地域。 |
| 400 | InvalidParameter.OssOutputDelivery | The specified parameter OssOutputDelivery is not valid. | 指定的參數 OssOutputDelivery 不合法。 |
| 400 | InvalidOssOutputDelivery.KeyPrefixMalformed | The prefix of the OSS key specified in the parameter OssOutputDelivery is not valid. | 參數 OssOutputDelivery 中指定的 prefix 不合法。 |
| 500 | InternalError.Dispatch | An error occurred when you dispatched the request. | 傳送請求時發生錯誤,請稍後重試。 |
| 403 | InvalidOssOutputDelivery.BucketAccessDenied | The error message returned by the OSS API is: %s | |
| 403 | InstanceIds.ExceedLimit | The number of instance IDs exceeds the upper limit. | 目標執行個體數量超過上限。 |
| 403 | Invocation.ExceedQuota | The invocation quota in the current region has been reached for today. | 在目前區域命令執行次數已到達今天的額度。 |
| 403 | ParameterCount.ExceedLimit | The maximum number of parameters is exceeded. | 自訂參數的個數超過限制。 |
| 403 | ParameterKey.ExceedLimit | The maximum length of a parameter name is exceeded. | 指定的參數 Key 長度超過可設定的最大長度。 |
| 403 | CmdContent.ExceedLimit | The maximum length of a command is exceeded. | 命令內容長度超過上限。 |
| 403 | ParameterKey.Duplicate | Parameter names cannot be duplicated. | 參數名稱不能重複,請確認後重試。 |
| 403 | Parameter.NotMatched | The passed-in parameters do not match the parameters defined when you created the command. | 傳入的自訂參數與建立命令時定義的自訂參數不匹配。 |
| 403 | ParameterType.NotSupported | The type of parameter value is not supported. | |
| 403 | Username.ExceedLimit | The length of the username exceeds the upper limit. | 使用者名稱長度超過上限。 |
| 403 | WindowsPasswordName.ExceedLimit | The length of the WindowsPasswordName exceeds the upper limit. | 指定的 WindowsPasswordName 參數長度超過上限。 |
| 403 | WindowsPasswordName.Missed | WindowsPasswordName must be specified when you create a Windows task. | 請求參數「命令類型 (WindowsPasswordName)」的值未提供。 |
| 403 | ParameterStore.NotSupported | Parameter Store is not supported in this region. | |
| 403 | TemporaryAccessKey.Error | The temporary accessKey is invalid. | |
| 403 | ParameterStore.InvalidParameters | The parameter is invalid in Parameter Store. | 未找到命令內容中的 {{oos:?}} 所指定的參數。 |
| 403 | ParameterStore.NoPermission | You have no access to Parameter Store. | |
| 403 | Operation.Forbidden | The operation is not permitted. | 目前子帳號沒有權限進行此操作。 |
| 403 | IdempotentParameterMismatch | The specified parameter has changed while using an already used clientToken. | 指定的客戶令牌已經被使用。 |
| 403 | IdempotentProcessing | The previous idempotent request(s) is still processing. | 先前的冪等請求仍在處理中,請稍後重試。 |
| 403 | InvalidLauncher.LengthLimitExceeded | The length of the parameter Launcher exceeds the limit of 1 KB characters. | 參數 Launcher 的長度超過了 1 KB 個字元的限制。 |
| 403 | InvalidParameterCharset.Parameters | The parameter Parameters contains illegal charset. | 命令參數包含非法字元集。 |
| 403 | CreateServiceLinkedRole.NoPermission | You do not have permission to create ServiceLinkedRole for output delivery. | 您沒有為 output 投遞功能建立服務連結角色的權限。 |
| 403 | InvalidTimeout.ExceedLimit | The specified parameter Timeout exceeds the upper limit. | |
| 404 | InvalidRepeatMode.NotFound | The specified repeat mode does not exist. | 指定的命令執行方式不存在。 |
| 404 | InvalidRegionId.NotFound | The RegionId provided does not exist in our records. | 地域資訊錯誤。 |
| 404 | InvalidInstance.NotFound | The specified instance does not exist. | 指定的執行個體不存在。 |
| 404 | InvalidCmdId.NotFound | The specified command ID does not exist. | 指定的 CommandId 參數有誤,請檢查參數值是否正確。您可以透過介面 DescribeCommands 查詢所有可用的 CommandId。 |
| 404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | 找不到對應的資源群組。 |
| 404 | InvalidTerminationMode.NotFound | The specified parameter TerminationMode does not exist. | 指定的參數 TerminationMode 不存在。 |
| 404 | InvalidOssOutputDelivery.BucketNotFound | The OSS bucket specified in the parameter OssOutputDelivery does not exist. | 參數 OssOutputDelivery 中指定的 bucket 不存在。 |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。