本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
aws:runCommand
– 在受管執行個體上執行命令
執行指定的命令。
注意
自動化僅支援一個 AWS Systems Manager Run Command動作的輸出。Runbook 可以包含多個 Run Command 動作,但一次僅一個動作支援輸出。
輸入
此動作支援大部分的傳送命令參數。如需詳細資訊,請參閱SendCommand。
- DocumentName
-
如果指令類型文件是您所擁有的 AWS,或者,請指定文件的名稱。如果您使用不同的文件與您共用 AWS 帳戶,請指定該文件的 Amazon 資源名稱 (ARN)。如需使用共用文件的詳細資訊,請參閱 使用 SSM 共用文件。
類型:字串
必要:是
- InstanceIds
-
要IDs在其中執行命令的執行個體。您最多可以指定 50 個IDs。
您也可以使用虛擬參數IDs來代替執行個體,
{{RESOURCE_ID}}
在目標群組中的所有執行個體上執行命令。如需這些虛擬參數的詳細資訊,請參閱註冊維護時段工作時使用虛擬參數。另一種方法是使用
Targets
參數將命令傳送到執行個體機群。該Targets
參數接受 Amazon 彈性計算雲(AmazonEC2)標籤。如需使用Targets
參數的詳細資訊,請參閱 大規模執行命令。類型: StringList
必要:否 (如果您未指定 InstanceIds 或使用
{{RESOURCE_ID}}
偽參數,則必須指定Targets
參數。) - 目標
-
使用您指定的「索引鍵、值」組合來鎖定執行個體的搜尋條件陣列。
Targets
如果您未IDs在呼叫中提供一或多個執行個體,則為必要項目。如需使用Targets
參數的詳細資訊,請參閱 大規模執行命令。Type: MapList (清單中對映的綱要必須與物件相符。) 如需詳細資訊,請參閱AWS Systems Manager API參考中的 Target。
必要:否 (如果未指定
Targets
,則必須指定 InstanceIds 或使用{{RESOURCE_ID}}
偽參數。)以下是範例。
- 參數
-
文件中指定的必要和選用參數。
類型:映射
必要:否
- CloudWatchOutputConfig
-
將命令輸出傳送至 Amazon CloudWatch 日誌的組態選項。如需將命令輸出傳送至 CloudWatch 記錄檔的詳細資訊,請參閱設定 Amazon CloudWatch 日誌 Run Command。
Type: StringMap (對映的綱要必須與物件相符。 若要取得更多資訊,請參閱〈參AWS Systems Manager API考〉CloudWatchOutputConfig中的)。
必要:否
以下是範例。
- 註解
-
關於命令,由使用者定義的資訊。
類型:字串
必要:否
- DocumentHash
-
文件的雜湊。
類型:字串
必要:否
- DocumentHashType
-
雜湊的類型。
類型:字串
有效值:
Sha256
|Sha1
必要:否
- NotificationConfig
-
傳送通知的組態。
必要:否
- 輸出 3 BucketName
-
用於命令輸出回應的 S3 儲存貯體名稱。
類型:字串
必要:否
- 輸出 3 KeyPrefix
-
字首。
類型:字串
必要:否
- ServiceRoleArn
-
ARN的 AWS Identity and Access Management (IAM) 角色。
類型:字串
必要:否
- TimeoutSeconds
-
等待命令傳遞給執行個體的時間 (以秒為 AWS Systems Manager SSM Agent單位)。如果在指定的值到達之前執行個體上的 SSM Agent 沒有收到命令,則命令的狀態會變更為
Delivery Timed Out
。類型:整數
必要:否
有效值:
輸出
- CommandId
-
命令的 ID。
- Status
-
命令的狀態。
- ResponseCode
-
命令的回應代碼。如果您執行的文件有 1 個以上的步驟,則不會傳回此輸出的值。
- 輸出
-
命令的輸出。如果您使用命令定位一個或多個實例,則不會返回輸出值。您可以使用
GetCommandInvocation
和ListCommandInvocations
API作業擷取個別執行個體的輸出。