Skip to content

imjerrybao/apex

Repository files navigation

Apex

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.

Installation

Download binaries or:

$ go get github.com/apex/apex/...

Runtimes

Currently supports:

  • Nodejs
  • Golang
  • Python

Features

  • 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

Example

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"}

Streaming input

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"}
...

Environment variables

Currently the following environment variables are used:

  • AWS_ACCESS_KEY AWS account access key
  • AWS_SECRET_KEY AWS account secret key
  • AWS_REGION AWS region

Links

License

MIT

About

Minimal AWS Lambda function manager with Go support.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages