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 从公开仓库中收录这些内容。

举报或申请下架