故障診斷 Systems Manager Automation - AWS Systems Manager

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

故障診斷 Systems Manager Automation

使用以下資訊以協助您對 AWS Systems Manager Automation (AWS Systems Manager 的一項功能) 的問題進行疑難排解。此主題包含根據自動化錯誤訊息解決問題的特定任務。

常見的自動化錯誤

本節包含常見自動化錯誤的資訊。

VPC 未定義 400

根據預設,自動化執行 AWS-UpdateLinuxAmi Runbook 或 AWS-UpdateWindowsAmi Runbook 時,系統會在預設 VPC (172.30.0.0/16) 中建立暫時執行個體。如果刪除預設 VPC,您會收到以下錯誤:

VPC not defined 400

如要解決此問題,您必須指定 SubnetId 輸入參數的值。

自動化執行無法啟動

如果您未正確設定 Automation 的 AWS Identity and Access Management (IAM) 角色和政策,自動化可能會因為存取遭拒錯誤或無效的擔任角色錯誤而失敗。

存取遭拒

以下範例說明自動化發生存取遭拒錯誤而無法啟動的情況。

存取 Systems Manager API 被拒

錯誤訊息User: user arn isn't authorized to perform: ssm:StartAutomationExecution on resource: document arn (Service: AWSSimpleSystemsManagement; Status Code: 400; Error Code: AccessDeniedException; Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

  • 可能原因 1:嘗試啟動自動化的使用者沒有叫用 StartAutomationExecution API 的許可。若要解決此問題,請將所需的 IAM 政策連接至用於啟動自動化的使用者。

  • 可能原因 2:嘗試啟動自動化的使用者有叫用 StartAutomationExecution API 的許可,但沒有使用特定執行手冊叫用 API 的許可。若要解決此問題,請將所需的 IAM 政策連接至用於啟動自動化的使用者。

由於缺少 PassRole 許可而存取遭拒

錯誤訊息User: user arn isn't authorized to perform: iam:PassRole on resource: automation assume role arn (Service: AWSSimpleSystemsManagement; Status Code: 400; Error Code: AccessDeniedException; Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

嘗試啟動自動化的使用者沒有所擔任角色的 PassRole 許可。若要解決此問題,請將 iam:PassRole 政策連接至嘗試啟動自動化的使用者角色。如需更多詳細資訊,請參閱 任務 2:將 iam:PassRole 政策連接至自動化角色

無效的擔任角色

在您執行 Automation 時,擔任角色會由 Runbook 提供或做為 Runbook 的參數值傳遞。如果未指定或正確設定擔任角色,可能會發生不同類型的錯誤。

格式錯誤的擔任角色

錯誤訊息The format of the supplied assume role ARN isn't valid. 擔任角色格式不正確。若要解決此問題,請確認您的 Runbook 中指定了有效的擔任角色,或在執行自動化時將其做為執行時間參數。

擔任角色無法擔任

錯誤訊息The defined assume role is unable to be assumed. (Service: AWSSimpleSystemsManagement; Status Code: 400; Error Code: InvalidAutomationExecutionParametersException; Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

  • 可能原因 1:擔任角色不存在。若要解決此問題,請建立角色。如需更多詳細資訊,請參閱 設定自動化。以下主題說明建立此角色的特定詳細資訊:任務 1:建立自動化的服務角色

  • 可能原因 2:擔任角色與 Systems Manager 服務沒有信任關係。若要解決此問題,請建立信任關係。如需詳細資訊,請參閱《IAM 使用者指南》中的我無法擔任角色

執行已開始,但狀態為失敗

動作特定的失敗

Runbook 包含步驟和依序執行的步驟。每個步驟會呼叫一個或多個 AWS 服務 API。API 會決定輸入、行為和步驟的輸出。有許多地方可能會發生錯誤導致步驟失敗。失敗訊息會指出錯誤發生的時間和位置。

若要在 Amazon Elastic Compute Cloud (Amazon EC2) 主控台查看失敗訊息,請選擇失敗步驟的 View Outputs (檢視輸出) 連結。若要從 AWS CLI 查看失敗訊息,請呼叫 get-automation-execution 並在失敗的 StepExecution 中尋找 FailureMessage 屬性。

在以下範例中,與 aws:runInstance 動作關聯的一個步驟失敗。每個範例都會探討一種不同類型的錯誤。

缺少映像

錯誤訊息Automation Step Execution fails when it's launching the instance(s). Get Exception from RunInstances API of ec2 Service. Exception Message from RunInstances API: [The image id '[ami id]' doesn't exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidAMIID.NotFound; Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)]. Please refer to Automation Service Troubleshooting Guide for more diagnosis details.

aws:runInstances 動作收到不存在的 ImageId 輸入。若要解決此問題,請以正確的 AMI ID 更新 Runbook 或參數值。

擔任角色政策沒有足夠的許可

錯誤訊息Automation Step Execution fails when it's launching the instance(s). Get Exception from RunInstances API of ec2 Service. Exception Message from RunInstances API: [You aren't authorized to perform this operation. Encoded authorization failure message: xxxxxxx (Service: AmazonEC2; Status Code: 403; Error Code: UnauthorizedOperation; Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)]. Please refer to Automation Service Troubleshooting Guide for more diagnosis details.

擔任角色沒有足夠的許可,無法在 EC2 執行個體上呼叫 RunInstances API。若要解決此問題,請將 IAM 政策連接至擁有呼叫 RunInstances API 之許可的擔任角色。如需詳細資訊,請參閱 方法 2:使用 IAM 設定自動化的角色

未預期的狀態

錯誤訊息Step fails when it's verifying launched instance(s) are ready to be used. Instance i-xxxxxxxxx entered unexpected state: shutting-down. Please refer to Automation Service Troubleshooting Guide for more diagnosis details.

  • 可能原因 1:執行個體或 Amazon EC2 服務發生問題。若要解決此問題,請登入執行個體或檢閱執行個體系統日誌,以了解執行個體開始關閉的原因。

  • 可能原因 2:針對 aws:runInstances 動作指定的使用者資料指令碼有問題或語法不正確。確認使用者資料指令碼的語法。此外,確認使用者資料指令碼並未關閉執行個體或呼叫其他指令碼以關閉執行個體。

動作特定的故障參考

步驟失敗時,失敗訊息可能會指出發生失敗時正在呼叫什麼服務。下表列出各動作呼叫的服務。表格也提供了各服務的相關資訊連結。

動作 此動作會叫用 AWS 服務 此服務的相關資訊 故障診斷內容

aws:runInstances

Amazon EC2

Amazon EC2 Linux 執行個體使用者指南

EC2 執行個體疑難排解

aws:changeInstanceState

Amazon EC2

Amazon EC2 Linux 執行個體使用者指南

EC2 執行個體疑難排解

aws:runCommand

Systems Manager

AWS Systems Manager Run Command

故障診斷 Systems Manager 執行命令

aws:createImage

Amazon EC2

Amazon Machine Images

aws:createStack

AWS CloudFormation

《AWS CloudFormation 使用者指南》https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html

疑難排解 AWS CloudFormation

aws:deleteStack

AWS CloudFormation

《AWS CloudFormation 使用者指南》https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html

疑難排解 AWS CloudFormation

aws:deleteImage

Amazon EC2

Amazon Machine Image

aws:copyImage

Amazon EC2

Amazon Machine Images

aws:createTag

Amazon EC2、Systems Manager

EC2 資源與標籤

aws:invokeLambdaFunction

AWS Lambda

AWS Lambda 開發人員指南

Lambda 故障診斷

自動化服務內部錯誤

錯誤訊息Internal Server Error. Please refer to Automation Service Troubleshooting Guide for more diagnosis details.

Automation 服務的一項問題使指定的 Runbook 無法正確執行。若要解決此問題,請聯絡 AWS Support。請提供執行 ID 和客戶 ID (若有)。

執行已開始,但發生逾時

錯誤訊息Step timed out while step is verifying launched instance(s) are ready to be used. Please refer to Automation Service Troubleshooting Guide for more diagnosis details.

aws:runInstances 動作中的一項步驟發生逾時。如果步驟動作執行的時間比步驟中 timeoutSeconds 的指定值更長,可能就會發生此情況。若要解決此問題,請為 aws:runInstances 動作中的 timeoutSeconds 參數指定較長的值。如果這樣未解決問題,請調查步驟執行時間比預期更久的原因