Connecting Lambda To Api Gateway

aws/agent-toolkit-for-aws/skills/specialized-skills/serverless-skills/connecting-lambda-to-api-gateway

作者 aws188af2f810ce無授權條款2.8K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Connects an existing AWS Lambda function to Amazon API Gateway by creating a REST or HTTP API with resource/method setup, Lambda proxy integration, permissions, and deployment. Always use this skill when connecting Lambda to API Gateway — it handles CORS, throttling, access logging, and production security hardening that are easy to miss.

僅含說明DevOps & Cloud
AI 產生的概覽

指導建立 Amazon API Gateway REST 或 HTTP API,並將其連接到現有的 AWS Lambda 函式。

功能
提供建立 API Gateway API、設定資源與方法,並透過 Lambda 代理整合將其連接到現有 Lambda 函式的流程。內容涵蓋授權類型、選用的 API 金鑰、CORS 設定、節流、存取日誌、部署與測試,並包含針對 502 錯誤、權限問題與瀏覽器 CORS 故障的疑難排解說明。
適用情境
當需要透過 API Gateway 對外暴露現有 Lambda 函式時使用。也適用於為這類 API 設定 CORS、授權、節流或存取日誌,或排查相關的 502、權限與 CORS 錯誤。
執行需求
僅為說明文件,未附帶指令碼。需要具備 AWS 存取權限、一個現有的 Lambda 函式,以及建立與部署 API Gateway API、管理 Lambda 叫用權限的權限。

Connecting Lambda to API Gateway

Overview

Domain expertise for creating Amazon API Gateway REST APIs and connecting them to existing Lambda functions. Covers API creation, resource and method setup, Lambda proxy integration, CORS configuration, security controls, deployment, and testing.

Connect a Lambda function to API Gateway

To create a REST API and wire it to a Lambda function, follow the procedure exactly. See Lambda to API Gateway connection procedure [blocked].

The procedure supports configurable authorization types (NONE, AWS_IAM, COGNITO_USER_POOLS, CUSTOM), optional API key requirements, CORS setup, and production security hardening including throttling and access logging.

Troubleshooting

502 Bad Gateway

The Lambda function must return a proxy-compatible response with statusCode, headers, and a stringified body. See the full procedure for format details.

Permission denied invoking Lambda

Ensure lambda:InvokeFunction permission was added with the correct API Gateway source ARN. See the full procedure for details.

CORS errors in browser

Verify enable_cors was set to true, the OPTIONS method was created, and CORS headers are configured in both method and integration responses.

來源與署名

來源:aws/agent-toolkit-for-aws位於skills/specialized-skills/serverless-skills/connecting-lambda-to-api-gateway提交188af2f

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架