Serverless Server lets you upload and run lambdas without much hassle about running and maintaining the server itself. It communicates through REST, so it is easy to use and extend. Applications can be build on top of it.
Prerequisites:
- Docker
- Java 7 or higher
The Server runs on Spring, which needs to be imported.
additional Prerequisites:
- Clone the repo:
https://github.com/serverlessserver/standard.git
- Import it into Intellij/Eclipse etc.
- Import Modules with Maven, given in
pom.xml
. - Run.
It works on Unix-like Systems. Windows should work too but no guarantee.
TODO make and link jar
- Download JAR.
- Run jar.
TODO make download link
- Start Docker.
- Download Serverless Server Image from Dockerhub.
- Run.
The Server listens to http://localhost:8080/
, so you can try things out.
If you have a lambda, you can upload it by sending a POST
request:
http://localhost:8080/lambdas
Headers:
Content-Type: application/json
Body:
{
"name":"yourlambdaname",
"runtimeAttributes":{
"language":"Python3",
"libraries":[],
"code":"print(\"Hello world\")"
}
}
You will receive a JSON Webtoken, which you should keep, because you'll need this to access your uploaded lambda.
If you want to update your lambda send a PUT
to:
http://localhost:8080/lambdas/yourlambdaname
Headers:
Content-Type: application/json
Authorization: Bearer tokenyougotwhenyouuploadedyourfunction
Body:
{
"name":"yourlambdaname",
"runtimeAttributes":{
"language":"Python3",
"libraries":[],
"code":"print(\"Bye world\")"
}
}
You will receive a JSON Webtoken, which you should keep, because you'll need this to access your updated lambda. The old JWT is not valid anymore.
If you want to check what you've uploaded, send a GET
to:
http://localhost:8080/lambdas/yourlambdaname
Headers:
Content-Type: application/json
Authorization: Bearer token
This will send you your lambda configuration.
If you want to execute your lambda, send POST
to:
http://localhost:8080/lambdas/yourlambdaname/execute
Headers:
Content-Type: application/json
Authorization: Bearer token
Body:
{
"times":"1",
"parameters":[]
}
If you want to generate a Subtoken e.g. for other apps to use (= only execute) the lambda, you can send a GET
with an expirydate to:
http://localhost:8080/lambdas/panda/token?expiryDate=yourexpirydate
Content-Type: application/json
Authorization: Bearer token
Note that subtokens can only execute and not upload/etc. So keep your mastertoken (token you get when you upload or update) to yourself to maintain your function and only give subtokens to customers.
If you want to delete your lambda, send a DEL
to:
http://localhost:8080/lambdas/yourlambdaname
Headers:
Content-Type: application/json
Authorization: Bearer token
More examples can be found under /src/testjava/edu/teco/serverless/
and also you can check out the documentation
and concepts.