Infra & Cloud
terraform
Advanced
AWS Lambda with API Gateway
Terraform for a Lambda function exposed via API Gateway v2 HTTP API.
terraform
resource "aws_lambda_function" "fn" {
function_name = var.name
filename = data.archive_file.fn.output_path
handler = "index.handler"
runtime = "nodejs20.x"
role = aws_iam_role.lambda.arn
}
resource "aws_apigatewayv2_api" "api" {
name = "${var.name}-api"
protocol_type = "HTTP"
}
resource "aws_apigatewayv2_integration" "fn" {
api_id = aws_apigatewayv2_api.api.id
integration_type = "AWS_PROXY"
integration_uri = aws_lambda_function.fn.invoke_arn
}
Prerequisites
- terraform >= 1.0
- AWS provider
Pro Tips
- → Grant API Gateway invoke permission with aws_lambda_permission.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- terraform
- Level
- Advanced
- Read time
- 6 min
- Published
- Dec 2025
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
AWS S3 Static Website
Terraform module to provision an S3 bucket for static website hosting.
terraform
·
Intermediate
AWS RDS Postgres Terraform
Terraform resource for an RDS PostgreSQL instance with encryption and backup.
terraform
·
Intermediate
ECS Task Force Stop
Force-stop all running ECS tasks in a service for emergency rollback.
bash
·
Intermediate