connecting-lambda-to-api-gateway
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConnecting Lambda to API Gateway
将Lambda连接至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.
本技能专注于创建Amazon API Gateway REST API并将其与现有Lambda函数连接的领域知识。涵盖API创建、资源与方法配置、Lambda代理集成、CORS配置、安全控制、部署及测试等内容。
Connect a Lambda function to API Gateway
将Lambda函数连接至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.
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.
要创建REST API并将其与Lambda函数关联,请严格遵循以下步骤。详见Lambda与API Gateway连接步骤。
该步骤支持可配置的授权类型(NONE、AWS_IAM、COGNITO_USER_POOLS、CUSTOM)、可选的API密钥要求、CORS设置,以及包含限流和访问日志记录的生产环境安全加固。
Troubleshooting
故障排查
502 Bad Gateway
502 Bad Gateway
The Lambda function must return a proxy-compatible response with ,
, and a stringified . See the full procedure for format details.
statusCodeheadersbodyLambda函数必须返回符合代理兼容格式的响应,包含、及字符串化的。格式详情请查看完整步骤。
statusCodeheadersbodyPermission denied invoking Lambda
调用Lambda时权限被拒绝
Ensure permission was added with the correct API Gateway
source ARN. See the full procedure for details.
lambda:InvokeFunction确保已添加带有正确API Gateway源ARN的权限。详情请查看完整步骤。
lambda:InvokeFunctionCORS errors in browser
浏览器中出现CORS错误
Verify was set to true, the OPTIONS method was created, and CORS
headers are configured in both method and integration responses.
enable_cors确认已设置为true,OPTIONS方法已创建,且CORS头已在方法响应和集成响应中配置。
enable_cors