Doing serverless
with Terraform.

Bring your application code and AWS infrastructure into one Terraform-based workflow. Build with reusable modules. Start with examples you can make your own.

  • Open source
  • Built on terraform-aws-modules
  • Focused on AWS
Manage application and infrastructure with Terraform
  1. API GatewayReceive
  2. LambdaCompute
  3. DynamoDBStore
An illustrative request path: an API receives a request, invokes Lambda, and accesses DynamoDB.

The approach

Your application is
more than a function.

APIs, permissions, events, and data belong to the same system. Manage them with a consistent approach.

01

One infrastructure language.

Describe serverless and supporting resources in Terraform.

02

Reusable building blocks.

Compose modules and inspect their source instead of starting from scratch.

03

A workflow that fits.

Use source packaging or existing artifacts, and keep the testing and CI steps your project needs.

One module’s output.
Another’s input.

Here, the API route uses the Lambda module’s function ARN. That reference tells Terraform how the resources depend on each other.

Review the plan, then apply changes through your deployment workflow. Keep application tests in your own pipeline.

Read the workflow guide
HTTP API example · API Gateway v2 + Lambda
module "api_gateway" {
  source  = "terraform-aws-modules/apigateway-v2/aws"
  version = "~> 6.1"

  name               = "serverless-http"
  protocol_type      = "HTTP"
  create_domain_name = false

  routes = {
    "ANY /" = {
      integration = {
        uri = module.lambda_function.lambda_function_arn
        payload_format_version = "2.0"
      }
    }
  }
}
module "lambda_function" {
  source  = "terraform-aws-modules/lambda/aws"
  version = "~> 8.12"

  function_name = "serverless-http"
  handler       = "index.lambda_handler"
  runtime       = "python3.12"
  source_path   = "${path.module}/src"
  publish       = true

  allowed_triggers = {
    api_gateway = {
      service = "apigateway"
      source_arn = "${module.api_gateway.api_execution_arn}/*/*"
    }
  }
}

Put your Python handler in src/index.py as lambda_handler. Configure the AWS provider with your region and credentials, then use these two module calls together. The route invokes the function; allowed_triggers grants API Gateway permission.

Inspect the full configuration

Start with something concrete.

Choose the part you want to inspect. Each link opens a separate upstream example.

Build a Lambda package

Compare building from source with using an existing archive.

Inspect source_path and local_existing_package.

Connect an HTTP API

Follow the API route’s connection to a Lambda function.

Inspect routes and allowed_triggers.

Supported services

The building blocks for
your next application.

Built on terraform-aws-modules, heavily used by AWS customers, with over 2 billion provisions. Explore the modules and examples behind the serverless.tf ecosystem.

Functions

2 services

APIs, events & delivery

7 services

Data & storage

4 services

Configuration & operations

5 services

A few useful answers

Before you build.

Scope, workflow, and where to go next.

What is serverless.tf?

A Terraform-based approach to AWS serverless applications, built around open-source modules and workflow guidance.

Can I use these modules with my organization’s compliance requirements?

compliance.tf provides variants of supported Terraform AWS modules with module-level controls, organization rules, and framework mappings. Review coverage for your module and requirements before adopting it. Explore compliance.tf.

Is it the Serverless Framework?

No. This project has nothing to do with Serverless Framework. serverless.tf uses Terraform and open-source AWS modules.

Do I need a particular CI/CD setup?

Keep the workflow that fits your project. Read the Lambda module’s packaging options and deployment guidance to see where it fits.

Which runtimes can I use?

Check AWS Lambda’s supported runtimes and the module’s build requirements for your code and packaging method.

Is this only for AWS?

This website and its module catalog focus on AWS.

Can I get commercial support?

Visit Betajob to discuss your Terraform and serverless project.

Make it your own

Put the approach into practice.

Find an example, read the code, and build from there.