Doing serverless with Terraform

Serverless Application & Infrastructure Lifecycle Management using Terraform and friends!

Give a star on GitHub, and share!

What is serverless.tf?

serverless.tf is an opinionated open-source framework for developing, building, deploying, and securing serverless applications and infrastructures on AWS using Terraform.

It has started as an organic response to the accidental complexity of many existing tools used by serverless developers.

This is not an official AWS or HashiCorp product, and not to be confused with the Serverless Framework.

Open-source
Using Terraform AWS modules
Simplifying serverless for all
Approved by Anton

Challenges with existing solutions

Most of the existing solutions require you to become a Serverless Superhero to get things done!

1. There are too many similar tools

Developers and DevOps/Cloud engineers have to deal with several types of tools:

  1. Serverless application frameworks (Serverless Framework, AWS Chalice, Zappa)
  2. Infrastructure management (Terraform, AWS CloudFormation)
  3. Application deployment (Shell scripts, Makefile, AWS CodeDeploy, AWS CLI)

serverless.tf approach:

Use Terraform (with or without Terragrunt) for comprehensive infrastructure management and serverless application deployments.


2. Different infrastructure resource scopes

Developers and DevOps/Cloud engineers manage different infrastructure services differently (for various reasons).

For example, serverless resources (API Gateways, AWS Lambda functions) managed as part of the application framework, and traditional resources (VPC, IAM roles, S3 buckets) - using infrastructure management tools.

serverless.tf approach:

Use a single tool that was created to manage infrastructure as code – Terraform – for all of your infrastructure resources.


3. Rather slow application development lifecycle

Developers like to have control of their environment as code. They also prefer running integration tests often before lengthy deployment cycles kick-off.

serverless.tf approach:

Using localstack in the development environment allows running tests on an infrastructure similar to the live environment very fast, and it saves costs, too. Since infrastructure is parametrized and stored as code, it is possible to bring it up and down with a single terraform apply. Be aware of the use-cases the tools like localstack were developed for and use them with caution.


4. Lack of high-quality reusable components

Some of the existing solutions support plugins that extend the functionality of the framework and to simplify the usage of infrastructure services.

In reality, often, developers still have to dive into those to learn internals and archive what they need. Adding functionality to those plugins usually requires writing Javascript code.

serverless.tf approach:

By relying on open-source Terraform AWS modules which have been developing by Betajob and huge community during several years, you get to build your serverless project on top of the verified, reusable components.

Please, contact Betajob if you want to sponsor the development of missing modules or features.

FAQ

Why not just use the Serverless Framework?

The challenges listed above apply to the Serverless Framework, too. One of the biggest for us at Betajob was infrastructure fragmentation between CloudFormation and Terraform.

What is the supported workflow?

serverless.tf does not restrict you from setting up your CI/CD workflow, which suits your needs, but it gives you the ways to control building, testing, deployments steps as code.

What runtimes are supported?

All of them. serverless.tf does not restrict you there, but it gives you a way to build, package, and deploy your code in a standardized way.

Who is developing and using this?

As far as we know, only we at Betajob are using serverless.tf framework, but Terraform AWS modules used by the framework are used by thousands of companies worldwide. We are going to continue developing Terraform modules we need for us and our clients.

What platforms are supported?

AWS only (for now).

Can I have commercial support for my Terraform and serverless project?

Yes, please reach out to Betajob.

What is the typical project for the serverless.tf approach?

We don't know this for sure yet, and we are going to find this out as more people use the framework and give feedback.

I want to use service X, but serverless.tf does not support it, what can I do?

We develop reusable solutions for our customers, or when we need them ourselves. Reach out to us if you want to discuss this or to sponsor the development of missing functionality.

Supported AWS Serverless Platform Services

See AWS Serverless official homepage for more information about each service, and Terraform AWS Modules for other compatible solutions.

AWS Lambda

AWS Lambda lets you run code without provisioning or managing servers.

Repository | Examples

Lambda@Edge

Lambda@Edge allows you to run Lambda functions at AWS Edge locations in response to Amazon CloudFront events.

Repository | Examples

Amazon API Gateway - HTTP/WebSocket

Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale.

Repository | Examples

Amazon DynamoDB

Amazon DynamoDB is a fast and flexible NoSQL database service for all applications that need consistent, single-digit millisecond latency at any scale.

Repository | Examples

Amazon Aurora Serverless

Amazon Aurora Serverless is an on-demand, auto-scaling configuration for Amazon Aurora (MySQL-compatible edition), where the database will automatically start up, shut down, and scale capacity up or down based on your application's needs.

Repository | Examples

Amazon S3

Amazon Simple Storage Service (Amazon S3) provides developers and IT teams with secure, durable, highly-scalable object storage.

Repository | Examples

Amazon SNS

Amazon SNS is a fully managed pub/sub messaging service that makes it easy to decouple and scale microservices, distributed systems, and serverless applications.

Repository | Examples

Amazon CloudWatch

Amazon CloudWatch is a monitoring service for AWS cloud resources and the applications you run on AWS.

Repository | Examples

Amazon SQS

Amazon SQS is a fully managed message queuing service that makes it easy to decouple and scale microservices, distributed systems, and serverless applications.

Repository | Examples

AWS CodeDeploy

AWS CodeDeploy is a service that automates application deployments to a variety of compute services including Amazon EC2, AWS Lambda, and instances running on-premises.

Repository | Examples

Contact us

Got any questions? Or want to sponsor development? Don't hesitate to reach out.

Follow @antonbabenko

and share serverless.tf with your network