This projects builds two Lambda functions built with Swift. Squared is a simple Lambda that returns the squared value of a number. SwiftApi is a simple Lambda function that triggers from an HTTP API.
You will not need Swift installed locally as we will use an Amazon Linux container to build the functions.
docker build -f Dockerfile . -t builder
sam build
from the root directory will compile each function and prepare for testing and deployment. Docsmake build-FunctionName
will build JUST the single Lambda function.
Run these commands from the root of the project.
sam local start-api
or
sam local invoke SwiftApi -e events/api-event.json
sam local invoke Squared -e events/squared-event.json
Use sam deploy
from the root of the project. Docs
I used both these amazing resources to figure this out.
- https://fabianfett.de/getting-started-with-swift-aws-lambda-runtime
- https://github.com/swift-server/swift-aws-lambda-runtime
Note: I am not an amazing makefile expert or Swift developer. Any feedback on my process is wanted and welcome