connecting-lambda-to-api-gateway

Creates an API Gateway REST API with Lambda proxy integration, permissions, and deployment.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/sakicodes/BuildFestHackathon26 --skill connecting-lambda-to-api-gateway-sakicodes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: connecting-lambda-to-api-gateway
Source: https://github.com/sakicodes/BuildFestHackathon26/tree/main/.agents/skills/connecting-lambda-to-api-gateway
Command: npx skills add https://github.com/sakicodes/BuildFestHackathon26 --skill connecting-lambda-to-api-gateway-sakicodes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Exposing an AWS Lambda function over HTTP requires many error-prone API Gateway steps—resource and method creation, proxy integration, invoke permissions, CORS, and deployment—that are easy to misconfigure or forget. ## Core Features & Use Cases - End-to-End API Setup: Creates a REST API, resource, method, and AWS_PROXY Lambda integration, then grants API Gateway invoke permission and deploys to a stage. - Security Hardening: Supports authorization types (AWS_IAM, Cognito, custom, NONE), API keys, throttling usage plans, and CloudWatch access logging for production deployments. - CORS and Troubleshooting: Configures OPTIONS methods and CORS headers, plus guidance for 502 errors, permission failures, and malformed Lambda proxy responses. - Use Case: You have an existing Lambda function and need a public HTTPS endpoint; the skill walks through creating the API, wiring the integration, and returning a testable invoke URL. ## Quick Start Connect my existing Lambda function to API Gateway and give me the deployed endpoint URL.

Frequently Asked Questions about connecting-lambda-to-api-gateway

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect a Lambda function to API Gateway?

Create a REST API with aws apigateway create-rest-api, add a resource and method, then configure an AWS_PROXY integration pointing to the Lambda function ARN. Finally, grant apigateway.amazonaws.com invoke permission and deploy the API to a stage.

How do I enable CORS on API Gateway for a Lambda API?

Create an OPTIONS method with a MOCK integration and add Access-Control-Allow-Origin, Access-Control-Allow-Headers, and Access-Control-Allow-Methods headers in both method and integration responses. Your Lambda function should also return CORS headers in its response.

Why does API Gateway return 502 Bad Gateway with Lambda?

A 502 usually means the Lambda response is not proxy-compatible. The function must return an object with statusCode, headers, and a stringified body field; returning a raw object as body causes a malformed response error.

What authorization options does API Gateway support for Lambda endpoints?

API Gateway supports AWS_IAM, COGNITO_USER_POOLS, CUSTOM authorizers, and NONE. For production, avoid NONE and combine IAM or Cognito authorization with API keys, throttling usage plans, and access logging.

Why does API Gateway get permission denied invoking Lambda?

API Gateway needs an explicit lambda:InvokeFunction permission added via aws lambda add-permission with principal apigateway.amazonaws.com. The source ARN must match the API Gateway execution ARN for your API, stage, and method.