You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取API Gateway触发的Lambda函数ID?排查API异常需查看其日志

How to Retrieve the Lambda Function ID Triggered by API Gateway

Absolutely! You can definitely track down the Lambda function ID linked to your API Gateway endpoint—here are straightforward methods using either the AWS Management Console or CLI:

Using the AWS Management Console

  • Head over to the API Gateway service in your AWS console.
  • Select the API that’s returning unexpected responses.
  • Navigate to the Resources tab, then pick the specific resource and HTTP method (like GET/POST) integrated with Lambda.
  • Scroll down to the Integration Request section in the method details.
  • You’ll see the Lambda function’s ARN (Amazon Resource Name) here. The function ID is the unique 12-character string right after function: in the ARN. For example, in arn:aws:lambda:us-east-1:123456789012:function:MyService-XyZ789AbC123, the ID is XyZ789AbC123.

Using the AWS CLI

If you prefer command-line tools, use these steps:

  1. First, fetch the integration details for your API method. Replace the placeholders with your actual values:
aws apigateway get-integration --rest-api-id YOUR_API_ID --region YOUR_REGION --resource-id YOUR_RESOURCE_ID --http-method YOUR_HTTP_METHOD
  1. The output will include a uri field with the Lambda ARN. Extract the 12-character function ID from this ARN as described above.

Alternatively, if you already know the Lambda function name but need its ID directly:

aws lambda get-function --function-name YOUR_FUNCTION_NAME --region YOUR_REGION

The response will show the FunctionId field explicitly, plus the full ARN containing the ID.

Quick Notes

  • If your API uses Lambda proxy integration, the setup will look slightly different, but the Lambda ARN (and thus the function ID) will still be visible in the Integration Request settings.
  • Double-check that you’re viewing the integration for the active API stage handling your live requests—staging and production stages sometimes link to different Lambda functions.

内容的提问来源于stack exchange,提问作者Ojasvi Monga

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:12:51