DEV Community

Robertino
Robertino

Posted on

⚙️ Create an API in Swift and Deploy It to AWS Lambda

📚 Learn how to create and deploy a serverless HTTP API using Swift and AWS Lambda.


In almost every real mobile application, we are probably going to need a backend side where our business logic will be handled. In most cases, there will be two different teams, one for mobile and one for the backend side of the project. But, what if we, as iOS developers, could write our own backend in our preferred language? Let's explore in this article how we can achieve this using Swift AWS Lambda Runtime together with AWS Lambda.

What is AWS Lambda?

In simple terms, it is a service provider by AWS in which we can run our code without the need to configure and manage a server. We just upload our code as a zip file, and AWS automatically does all the configurations needed in the server to make our software available.

One of the main differences between this approach and having a dedicated server, in addition to simpler administration, is that if at some point we need to increase our processing power to scale up our application, AWS Lambda does that automatically for us if we design the application correctly.

You can check out more at this link.

Swift AWS Lambda Runtime

A custom AWS Lambda runtime is basically a library that is in charge of managing and executing the Lambda function's code when it is called. With Swift AWS Lambda Runtime, we can now write serverless code in Swift and make it ready for use with AWS Lambda service.

Creating Our HTTP API

For this tutorial, we will create a simple HTTP API in Swift and expose it through API Gateway, which is another service available in AWS suite that allows us to expose our Lambda function as HTTP endpoints.

Prerequisites

  • Have XCode installed
  • Have an AWS account.
  • Have an Auth0 account.
  • Have Docker installed in your machine to compile the code that we will upload to AWS.

Read more...

Top comments (0)