aws avatar

Connecting Lambda To Api Gateway

If you've ever wired up Lambda to API Gateway manually and forgotten the invoke permission or botched the CORS setup, this walks you through the complete procedure. It handles REST API creation, resource and method configuration, Lambda proxy integration, and the security bits that are easy to skip like throttling and access logging. Supports different auth types including IAM, Cognito, and custom authorizers. The troubleshooting section covers the usual gotchas like 502 errors from malformed proxy responses and permission denied issues. Honestly most useful as a checklist to make sure you didn't miss something rather than learning this from scratch.

skills.sh installs
7K
GitHub stars
3.4K
last updated
Aug 21, 2026

Install

$ npx -y skills add aws/agent-toolkit-for-aws --skill connecting-lambda-to-api-gateway --agent claude-code

Installs into .claude/skills of the current project.

Files

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

Sponsors

Details

Repository
github.com/aws/agent-toolkit-for-aws
Categories
Backend & APIs, Security, DevOps & CI/CD, AI & Agent Building, Cloud & Infrastructure
First seen
May 16, 2026

More from aws/agent-toolkit-for-aws

All 56
1prisma avatarprisma-database-setupprisma/skillsGuides for configuring Prisma with different database providers (PostgreSQL, MySQL, SQLite, MongoDB, etc.). Use when setting up a new project, changing database417.9Kskills.sh installs
2prisma avatarprisma-orm-setupprisma/skillsSet up Prisma ORM in an application, connect its database, or troubleshoot the connection of an existing Prisma 6, 7, or 8 app. Defaults new applications to Pri95.7Kskills.sh installs
3clerk avatarclerk-backend-apiclerk/skillsClerk Backend REST API explorer and executor. Browse tags, inspect endpoint schemas, and execute authenticated requests. Use when listing users, managing organi56.1Kskills.sh installs
4supabase avatarsupabase-serversupabase/serverUse when planning or writing server-side code that uses `@supabase/server` — Edge Functions, Hono apps, webhook handlers, or any backend that creates Supabase c10.6Kskills.sh installs
5giuseppe-trisciuoglio avatardrizzle-orm-patternsgiuseppe-trisciuoglio/developer-kitProvides comprehensive Drizzle ORM patterns for schema definition, CRUD operations, relations, queries, transactions, and migrations. Proactively use for any Dr5.7Kskills.sh installs
6vtex avatarvtex-io-graphql-apivtex/skillsApply when working with GraphQL schema files in graphql/ or implementing resolvers in node/resolvers/ for VTEX IO apps. Covers schema.graphql definitions, @cach1.3Kskills.sh installs