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- Existing AWS Lambda function
- AWS credentials configured for the agent
- Appropriate IAM permissions to create API Gateway resources
How to use connecting-lambda-to-api-gateway
- 1.Install the skill using the provided npm command
- 2.Identify the Lambda function to connect
- 3.Run the connection procedure specifying API type (REST or HTTP)
- 4.Configure authorization type and CORS settings as needed
- 5.Review and deploy the created API Gateway configuration
- 6.Test the API endpoint to verify Lambda invocation works
Use cases
- 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
- AWS developers building serverless APIs
- Backend engineers deploying Lambda-based microservices
- DevOps engineers configuring API security and monitoring
connecting-lambda-to-api-gateway FAQ
Lambda must return a proxy-compatible response with statusCode, headers, and a stringified body. See the procedure for exact format details.
This typically means the Lambda response format is incorrect. Ensure it includes statusCode, headers, and body fields as specified in the procedure.
Verify that the lambda:InvokeFunction permission was added with the correct API Gateway source ARN. The procedure includes the exact permission setup.
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.
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.

connecting-lambda-to-dynamodb
Connect AWS Lambda to DynamoDB with IAM roles, streams, and event source mapping.

connecting-to-data-source
Create and test AWS Glue connections to JDBC databases, Redshift, Snowflake, and BigQuery.

connecting-vpcs-with-peering
Establishes VPC peering connections between two VPCs for direct private network connectivity. Always use this skill when creating or managing VPC peering — it validates CIDR overlap, updates all route tables in both VPCs, configures DNS resolution, and provides security group guidance that are critical for correct connectivity.

creating-amazon-aurora-db-cluster-with-instances
Creates a complete Amazon Aurora database cluster with instances, handling cluster creation, instance provisioning, and Secrets Manager password management in the proper sequence. Use when setting up new Aurora MySQL or PostgreSQL clusters with production-ready configuration.

creating-api-gateway-stage
Create fully configured API Gateway stages with logging, tracing, throttling, and security controls.

creating-data-lake-table
Create managed Iceberg tables on Amazon S3 with automatic compaction and snapshot management.