Quick Start

Get up and running with sls.tf in 5 minutes

1. Add sls.tf to your project

Add sls.tf as a Git submodule inside your Terraform project:

git submodule add https://github.com/sls-tf/sls.tf.git modules/sls.tf
git submodule update --init --recursive

2. Create your Terraform root

Point the module at your existing serverless.yml:

main.tf

terraform {
  required_version = ">= 1.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

module "serverless" {
  source      = "./modules/sls.tf"
  config_path = "${path.root}/serverless.yml"
}

3. Write a minimal serverless.yml

serverless.yml

service: hello-world
provider:
  name: aws
  runtime: nodejs20.x
  region: us-east-1
  stage: dev

functions:
  hello:
    handler: index.handler
    events:
      - http:
          path: /hello
          method: get

4. Deploy

terraform init
terraform plan
terraform apply

Terraform will create the Lambda function, IAM execution role, API Gateway REST API, and all required permissions — everything sls.tf infers from your serverless.yml.

Access outputs

After terraform apply, retrieve the API endpoint and function ARNs:

terraform output -json

# Example output:
# {
#   "api_gateway_invoke_url": "https://abc123.execute-api.us-east-1.amazonaws.com/dev",
#   "function_arns": { "hello": "arn:aws:lambda:us-east-1:..." },
#   "function_names": { "hello": "hello-world-dev-hello" }
# }

Next steps