Apex is a small tool for deploying and managing AWS Lambda functions. With shims for languages not yet supported by Lambda, you can use Golang out of the box.
Download binaries or:
$ go get github.com/apex/apex/...
Currently supports:
- Nodejs
- Golang
- Python
- Supports languages Lambda does not natively support via shim
- Binary install (useful for continuous deployment in CI etc)
- Command-line function invocation with JSON streams
- Transparently generates a zip for your deploy
This example shows how you can use Apex to launch a simple Node.js echo function.
First create the function implementation in "index.js".
exports.handle = function(e, ctx) {
ctx.succeed(e)
}
Next create a "package.json" with the function name a configuration:
{
"name": "echo",
"description": "Echo request example",
"runtime": "nodejs",
"memory": 128,
"timeout": 5
}
Create and deploy the function:
$ apex deploy
Create a file with a sample request "request.js":
{
"event": {
"hello": "world"
},
"context": {
"user": "Tobi"
}
}
Test out your new function:
$ apex invoke < request.json
{"hello":"world"}
The invoke
sub-command allows you to stream input over stdin:
$ apex invoke < request.json
This not only works for single requests, but for multiple, as shown in the following example using phony(1):
$ echo -n '{ "event": { "user": "{{name}}" } }' | phony | apex invoke
{"user":"Delmer Malone"}
{"user":"Jc Reeves"}
{"user":"Luna Fletcher"}
...
Currently the following environment variables are used:
AWS_ACCESS_KEY
AWS account access keyAWS_SECRET_KEY
AWS account secret keyAWS_REGION
AWS region
MIT