如何使用 SAW 執行手冊來疑難排解 API Gateway HTTP 調用錯誤?

1 分的閱讀內容
0

我想使用 AWSSupport-TroubleshootAPIGatewayHttpErrors AWS Support Automation Workflow (SAW) 執行手冊來疑難排解 Amazon API Gateway 錯誤。

簡短說明

AWSSupport-TroubleshootAPIGatewayHttpErrors 執行手冊提供自動化解決方案,以尋找並疑難排解因 API Gateway HTTP 請求造成的錯誤。當您設定 API 以記錄所有資源和方法請求時,可以使用此執行手冊來疑難排解 4xx 和 5xx 錯誤。

若需如何設定記錄功能的詳細資訊,請參閱](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html)在 API Gateway 中設定 REST API 的 CloudWatch 記錄功能[。

如需 SAW 的相關資訊,請參閱 AWS Support Automation Workflows (SAW)

解決方法

在嘗試擷取和分析 Amazon CloudWatch Logs 之前,AWSSupport-TroubleshootAPIGatewayHttpErrors執行手冊會驗證 API、資源、方法和階段。

執行自動化的目前使用者或 AWS Identity and Access Management (IAM) 服務角色必須具有以下權限:

  • apigateway:GET
  • logs:GetQueryResults
  • logs:StartQuery
  • ssm:DescribeAutomationExecutions
  • ssm:GetAutomationExecution
  • ssm:DescribeAutomationStepExecutions
  • ssm:StartAutomationExecution
  • ssm:DescribeDocument
  • ssm:GetDocument
  • ssm:ListDocuments

先決條件

在執行此執行手冊之前,請確定您的 IAM 使用者或角色具有正確權限。這些權限包括特定的 AWS Systems Manager 權限,以及本文前幾區段中涵蓋的其他特定服務權限。

執行 AWSSupport-TroubleshootAPIGatewayHttpErrors 自動化

  1. 開啟 AWSSupport-TroubleshootAPIGatewayHttpErrors 執行手冊。
    注意: 執行手冊位於 us-east-1 AWS 區域中。

  2. 選取執行自動化

    對於輸入參數,請輸入下列內容:

    • **RestApiId (必填):**需要疑難排解的 API ID。
    • **StageName (必填):**已部署階段的名稱。
    • **ResourcePath (必填):**方法的資源路徑。
    • **HttpMethod (必填):**已設定資源路徑的方法。
    • **StartTime (必填):**查詢 CloudWatch Logs 的開始日期和時間。格式必須是 yyyy-MM-ddTHH:mm:ss,且時區必須是 UTC。
    • **EndTime (必填):**查詢 CloudWatch Logs 的結束日期和時間。格式必須是 yyyy-MM-ddTHH:mm:ss,且時區必須是 UTC。
    • **AccessLogs (必填):**提供存取日誌是否進行分析的相關資訊。
    • **ExecutionId (選填):**發生錯誤的請求執行 ID。
    • **AutomationAssumeRole (選填):**IAM 角色的 Amazon Resource Name (ARN),可讓 Automation (Systems Manager 的功能之一) 代表您執行動作。如果未指定角色,Automation 則會使用啟動執行手冊的使用者權限。
  3. 選取執行。自動化啟動。

  4. 自動化完成後,請檢閱輸出區段以取得詳細結果。

注意: 即使未找到任何日誌,執行手冊也能成功完成。