mcpField
C
connecting-lambda-to-api-gateway

connecting-lambda-to-api-gateway

github.com/awsCloud & DevOps3.3k6.7k installsUpdated 1d ago
Repository

About connecting-lambda-to-api-gateway

A skill for developers connecting existing Lambda functions to Amazon API Gateway REST APIs. It covers integration setup, security, deployment, testing, and common troubleshooting paths.

Key features

  1. 01Create REST APIs, resources, and methods
  2. 02Configure Lambda proxy integration
  3. 03Set up CORS and authorization
  4. 04Deploy and test APIs
  5. 05Troubleshoot invocation and gateway errors

Use cases

  1. 01Expose an existing Lambda function as a REST API
  2. 02Configure CORS for browser clients
  3. 03Set API keys or authorization controls

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/aws/agent-toolkit-for-aws --skill connecting-lambda-to-api-gateway

After installing, type/connecting-lambda-to-api-gatewayin Claude Code to confirm it loaded.

Bundled filesreferences/lambda-gateway-api.md

Details

From the project README

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.

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.

Comments

Markdown supported