TERRAFORM MODULE

Serverless & SAM
→ Terraform

Drop your SAM template.yaml or serverless.yml. Get production Terraform. No rewrites.

v0.3.16 / MIT License / AWS
serverless.yml
service: my-api

provider:
  name: aws
  runtime: nodejs20.x
  stage: prod

functions:
  hello:
    handler: src/hello.handler
    events:
      - httpApi:
          path: /hello
          method: GET
main.tf
module "api" {
  source = "git::https://github.com/
    sls-tf/sls.tf.git?ref=v0.3.16"

  config_path   = "./serverless.yml"
  aws_region    = "us-east-1"
}

# Lambda, API GW, IAM roles —
# all provisioned automatically.
→ AWS SAM Support

First-class support for AWS SAM template.yaml — Globals, Parameters, and CloudFormation intrinsics included. Serverless Framework serverless.yml works the same way. Point at either; no migration step.

→ Variable Resolution

Resolves ${self:custom.foo}, environment-specific overrides, and nested references at plan time.

→ TypeScript Configs

Evaluates TypeScript serverless.ts exports, including async factory functions that return the config object.

→ API Gateway

Provisions HTTP API v2 and REST API v1 resources, routes, integrations, and custom authorizers.

→ DynamoDB Tables

Creates tables declared in resources.Resources with keys, billing mode, TTL, and stream settings preserved.

→ IAM Roles

Synthesises least-privilege execution roles per function, merging provider-level and function-level statements.

Reference the module. Point at your config. Done.

main.tf
module "service" {
  source = "git::https://github.com/sls-tf/sls.tf.git?ref=v0.3.16"

  config_path   = "./template.yaml"  # serverless.yml, template.yaml, or serverless.ts
  config_format = "sam"             # yaml | sam | typescript
  aws_region    = "us-east-1"
}
One command
terraform init
Fetches the module. No npm install. No CLI setup.
Pin a version
?ref=v0.3.16
Semver tags on every release. Upgrade on your schedule.

Start converting in 5 minutes

Read the docs →