Building Swift Serverless REST API with AWS Lambda & DynamoDB

Alfian Losari
20 min readJul 12, 2020
Swift REST API & AWS Lambda & DynamoDB

Last month, The Swift Core Team & Swift Server Work Group had announced the availability of Swift AWS Lambda Runtime as well as support of Swift on Amazon Linux 2 OS. With both of this announcement, we finally have some official support to run Swift on AWS Lambda environment.

Swift has many advantages such as low memory footprint, high performance, and quick start time. The Swift AWS Lambda runtime also uses SwiftNIO to provide high performance non blocking networking engine for us to run asynchronous event driven code.

The runtime itself provides built-in support for many Lambda supported events such as HTTP request event from API Gateway, S3 object storage event, Simple Notification Service, and Simple Queue Service.

What We Will Build

In this tutorial, we’ll build a simple Swift Serverless REST API endpoints to create, update, delete, and retrieve list of todo. Here are the topics we’ll learn:

  1. Swift Lambda Runtime to handle API Gateway request event.
  2. Swift AWS DynamoDB SDK to persist the todo data in the Cloud.
  3. SwiftNIO to handle asynchronous event processing in network using EventLoopFuture.
  4. Docker to build and package the Swift binary ready for AWS Lambda Custom provided runtime.
  5. Serverless Framework to provision and deploy to AWS Lambda with IAM Role.

You can download the completed project Source from the GitHub repository. I have provided the backend and iOS client app under one repository. Please follow the instruction on the README file to build.

Alfian Losari

Mobile Developer and Lifelong Learner. Currently building super app @ Go-Jek. Xcoding with Alfian at