Connecting Lambda To Api Gateway

by aws188af2f810ceNo license2.8K starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated today

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.

Instructions onlyDevOps & Cloud
AI-generated overview

Guides creating an Amazon API Gateway REST or HTTP API and connecting it to an existing AWS Lambda function.

What it does
Provides a procedure for creating an API Gateway API, setting up resources and methods, and wiring them to an existing Lambda function through Lambda proxy integration. It covers authorization types, optional API keys, CORS configuration, throttling, access logging, deployment, and testing, and includes troubleshooting for 502 errors, permission problems, and browser CORS failures.
When to use it
Use when an existing Lambda function needs to be exposed through API Gateway. Also useful when configuring CORS, authorization, throttling, or access logging for such an API, or when debugging related 502, permission, or CORS errors.
Requirements
Instructions only; no scripts are shipped. It assumes access to AWS with an existing Lambda function and permissions to create and deploy API Gateway APIs and manage Lambda invoke permissions.

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.

Source and attribution

Source:aws/agent-toolkit-for-awsinskills/specialized-skills/serverless-skills/connecting-lambda-to-api-gatewayat commit188af2f

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal