PluginBench
Skill
Pass
Audit score 90

connecting-lambda-to-api-gateway

aws/agent-toolkit-for-aws

Connect AWS Lambda functions to API Gateway with CORS, security, and deployment automation.

What is connecting-lambda-to-api-gateway?

This skill creates and configures Amazon API Gateway REST or HTTP APIs connected to existing Lambda functions. Use it when you need to expose Lambda functions as HTTP endpoints with proper proxy integration, CORS handling, throttling, access logging, and production security controls.

  • Create REST or HTTP APIs in API Gateway
  • Set up resources and methods with Lambda proxy integration
  • Configure CORS headers and OPTIONS methods
  • Apply authorization types (NONE, AWS_IAM, COGNITO_USER_POOLS, CUSTOM)
  • Enable throttling, access logging, and API key requirements
  • Deploy APIs and test Lambda invocation

How to install connecting-lambda-to-api-gateway

npx skills add https://github.com/aws/agent-toolkit-for-aws --skill connecting-lambda-to-api-gateway
Prerequisites
  • Existing AWS Lambda function
  • AWS credentials configured for the agent
  • Appropriate IAM permissions to create API Gateway resources
Claude Code
Cursor
Windsurf
Cline

How to use connecting-lambda-to-api-gateway

  1. 1.Install the skill using the provided npm command
  2. 2.Identify the Lambda function to connect
  3. 3.Run the connection procedure specifying API type (REST or HTTP)
  4. 4.Configure authorization type and CORS settings as needed
  5. 5.Review and deploy the created API Gateway configuration
  6. 6.Test the API endpoint to verify Lambda invocation works

Use cases

Good for
  • Expose a Lambda function as a public REST API endpoint
  • Add CORS support to allow browser-based clients to call Lambda
  • Secure Lambda invocation with IAM or Cognito authorization
  • Set up API throttling and access logging for production workloads
  • Connect multiple Lambda functions to different API Gateway resources
Who it's for
  • AWS developers building serverless APIs
  • Backend engineers deploying Lambda-based microservices
  • DevOps engineers configuring API security and monitoring

connecting-lambda-to-api-gateway FAQ

What response format does my Lambda function need?

Lambda must return a proxy-compatible response with statusCode, headers, and a stringified body. See the procedure for exact format details.

Why am I getting 502 Bad Gateway errors?

This typically means the Lambda response format is incorrect. Ensure it includes statusCode, headers, and body fields as specified in the procedure.

How do I fix permission denied errors when invoking Lambda?

Verify that the lambda:InvokeFunction permission was added with the correct API Gateway source ARN. The procedure includes the exact permission setup.

How do I enable CORS for browser clients?

Set enable_cors to true during configuration, ensure the OPTIONS method is created, and verify CORS headers are configured in both method and integration responses.

Can I use different authorization types?

Yes, the skill supports NONE, AWS_IAM, COGNITO_USER_POOLS, and CUSTOM authorization types. Configure the appropriate type during API setup.

Full instructions (SKILL.md)

Source of truth, from aws/agent-toolkit-for-aws.


name: connecting-lambda-to-api-gateway description: 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. version: 1

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.

Related skills

More from aws/agent-toolkit-for-aws and the wider catalog.