Git Product home page Git Product logo

apex's Introduction

Apex Serverless Architecture

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/cmd/apex

Runtimes

Currently supports:

  • Nodejs
  • Golang
  • Python

Features

  • Supports languages Lambda does not natively support via shim, such as Go
  • Binary install (useful for continuous deployment in CI etc)
  • Project level function and resource management
  • Configuration inheritance and overrides
  • Command-line function invocation with JSON streams
  • Transparently generates a zip for your deploy
  • Function rollback support
  • Tail function CloudWatchLogs
  • Concurrency for quick deploys
  • Dry-run to preview changes

Example

Apex projects are made up of a project.json configuration file, and zero or more Lambda functions defined in the "functions" directory. Here's an example file structure:

project.json
functions
├── bar
│   ├── function.json
│   └── index.js
├── baz
│   ├── function.json
│   └── index.js
└── foo
    ├── function.json
    └── index.js

The project.json file defines project level configuration that applies to all functions, and defines dependencies. For this simple example the following will do:

{
  "name": "example",
  "description": "Example project"
}

Each function uses a function.json configuration file to define function-specific properties such as the runtime, amount of memory allocated, and timeout. This file is completely optional, as you can specify defaults in your project.json file. For example:

{
  "name": "bar",
  "description": "Node.js example function",
  "runtime": "nodejs",
  "memory": 128,
  "timeout": 5,
  "role": "arn:aws:iam::293503197324:role/lambda"
}

Now the directory structure for your project would be:

project.json
functions
├── bar
│   └── index.js
├── baz
│   └── index.js
└── foo
    └── index.js

Finally the source for the functions themselves look like this in Node.js:

console.log('start bar')
exports.handle = function(e, ctx) {
  ctx.succeed({ hello: 'bar' })
}

Or using the Golang Lambda package, Apex supports Golang out of the box with a Node.js shim:

package main

import (
  "encoding/json"

  "github.com/apex/apex"
)

type Message struct {
  Hello string `json:"hello"`
}

func main() {
  apex.HandleFunc(func(event json.RawMessage, ctx *apex.Context) (interface{}, error) {
    return &Message{"baz"}, nil
  })
}

Apex operates at the project level, but many commands allow you to specify specific functions. For example you may deploy the entire project with a single command:

$ apex deploy

Or whitelist functions to deploy:

$ apex deploy foo bar

See the Wiki for more information.

Credentials

Via environment variables:

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

Via ~/.aws configuration:

  • AWS_PROFILE profile name to use
  • AWS_REGION AWS region (aws-sdk-go does not read ~/.aws/config)

Links

Contributors

Badges

Build Status GoDoc


tjholowaychuk.com  ·  GitHub @tj  ·  Twitter @tjholowaychuk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.