• Stars
    star
    377
  • Rank 113,535 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A framework for building JavaScript Applications with AWS API Gateway and Lambda

Build Status Code Climate

A framework for building JavaScript Applications with AWS API Gateway and Lambda

Make "Serverless" Simple

Amazon Web Services API gateway and Lambda are great tools for building and deploying "serverless" applications. But using them to deploy more than a couple functions/endpoints involves an excessive amount of manual work such as zipping files, uploading via the web UI, configuring paths and function names, etc. Shep is built to automate as many of these tasks as possible, giving you the ability to deploy an entire API and suite of lambda functions with one CLI command.

Getting Started With Shep

Prerequisites

It will be helpful to have some existing experience with API gateway and Lambda. If you have never used either of these tools before, it is recommended to setup a function manually to see how things are done. Please refer to Amazon's own getting started guide

AWS credentials

Shep will require your amazon credentials and will load them using the same methods as the AWS CLI tool meaning you must have setup the AWS CLI tool before using shep. Consult Amazon's CLI documentation for instructions.

AWS S3 Build Artifacts

Shep stores build artifacts on S3 so it can skip the upload step when your functions don't change. By default, Lambda won't update the version of an alias unless the function has changed - so this will come into effect for deploys of config changes. This isn't enabled by default, to enable it add the name of the S3 bucket to the "bucket" field in the shep version of your package.json.

Installation

npm install -g shep
// Optionally install shep in your project. The global shep will run the project's shep
npm install --save-dev shep

Add a few lines to your package.json. Your account id can be found on the billing page of your aws account.

{
  "name": "my-great-package",
    "shep": {
      "accountId": "XXXXX",
      "region": "us-east-1",
      "bucket": "my-great-bucket", // optional upload builds to s3 instead of directly to lambda
      "dist": "dist" // optional, customize the dist folder location
    }
}

Environments

Environments for a shep project are defined by the aliases on the functions associated with a project. Environments are created through shep deploy --env new_env and managed by using the shep config commands. Shep takes a strong stance against having different environments for different functions within a project. If you attempt a command which requires the listing of environments and there is a mismatch detected, then shep will throw a EnvironmentMistmach error until you remedy the issue. Most issues can be automatically fixed by using shep config sync, the only issues this can't solve are conflicting environment variable values. Conflicting value issues can be solved by using shep config set my_env CONFLICT_VARIABLE=value.

Custom Builds Commands

By default shep builds all your functions using webpack. If your project requires a different build process, then edit your package.json. Before running your build command, shep populates the PATTERN environment variable which can be accessed as process.env.PATTERN in your build command. Be aware that using your own build process will break pattern matching for shep build unless your build command respects the PATTERN variable.

{
  "shep": {
    "buildCommand": "custom-build --with-flag"
  }
}

Creating a new API

1. Configure AWS

Since Shep uses the same credentials as the AWS CLI, all you need to do is configure the cli. This can be accomplished via aws configure.

2. Create a new Shep project

Run shep new my-project
This will create and configure a Shep project called 'my-project' in the my-project directory. Change into this directory.

3. Create a new endpoint and function

Run shep generate endpoint /hello and follow the prompts.
This creates a new endpoint as well as a new function for that endpoint. Specifically, it adds a path to api.json that is configured to trigger the newly created function.

4. Deploy

Run shep deploy --env development
This command does a couple things in order to deploy your project:

  • Uses webpack to build your functions. This is equivalent to running shep build.
  • Creates or updates the Lambda functions associated with your project. This includes creating a new version of the function as well as updating the alias such that development will point to the version you just created. For more on versioning please consult Amazon's own documentation.
  • Creates or updates the API Gateway associated with your project and deploys it to the specified stage, development in this case.

You can test your endpoint by visiting the API URL printed out after the project is deployed. Visiting the /hello endpoint which should show success!.

CLI Documentation

CLI documentation can be found in DOCS.md

Upgrading

Read the migration docs for information on upgrading major version changes

Why the name 'shep'?

It was called 'shepherd' at first because it was helpful for dealing with lambda but everyone kept shortening it to 'shep' so we changed the name

Other Tools

Serverless Apex Gordon DEEP Claudia.js

Development

Pull requests welcome!

Test: npm test

Rebuild on file change: npm run compile -- -w

Publish: npm run pub "publish" is reserved by npm

More Repositories

1

mobiledoc-kit

A toolkit for building WYSIWYG editors with Mobiledoc
JavaScript
1,549
star
2

ember-restless

A lightweight data model library for Ember.js
JavaScript
313
star
3

ts-eager

Fast TypeScript runner using esbuild for eager compilation
JavaScript
216
star
4

bluestream

A collection of streams that work well with promises (through, map, reduce). Think Through2 with promises
TypeScript
103
star
5

ember-mobiledoc-editor

JavaScript
86
star
6

streaming-iterables

A Swiss army knife for async iterables. Designed to replace your streams.
TypeScript
43
star
7

ember-cli-amp

render valid Google's Accelerated Mobile Pages project (AMP) pages with your ember app and Fastboot
JavaScript
32
star
8

mobiledoc-dom-renderer

JavaScript
25
star
9

graphql-helper

A simple helper library for constructing GraphQL queries.
JavaScript
24
star
10

ember-cli-deploy-fastboot-lambda

JavaScript
23
star
11

nemesis-db

An Open Source Port of the Gradius API Storage Engine
TypeScript
22
star
12

sammie

Serverless Application Model Made Infinitely Easier
JavaScript
21
star
13

coloring-palette

🎨 🖌 A library to generate color palettes based on Material UI's approach to colors
TypeScript
20
star
14

radredis

Basic redis backed object modeling for Node.
JavaScript
19
star
15

dynamo-graph

Low-level graph operations implemented on DynamoDB
JavaScript
18
star
16

ember-mobiledoc-dom-renderer

Render mobiledoc documents in an ember app
JavaScript
15
star
17

ember-cli-image

Stateful image components for Ember.js
JavaScript
14
star
18

statsd-lambda

A simple UDP based statsd client designed for functions as a service
TypeScript
12
star
19

aws-sudo

JavaScript
10
star
20

radql

Opinionated, service-oriented, GraphQL architecture
JavaScript
9
star
21

yajsondiff

Yet another JSON diff utility, for generating and applying patches
JavaScript
8
star
22

mobiledoc-text-renderer

A text renderer for Mobiledoc
JavaScript
7
star
23

redis_assist

Redis Assist - Easy Redis Backed Object Modeling
Ruby
7
star
24

redis-loader

A Redis command batcher
TypeScript
6
star
25

chai-graphql

GraphQL response matcher for Chai assertion library
JavaScript
6
star
26

mobiledoc-vdom-renderer

🔮 Render Mobiledoc as VDOM by passing your React or React-like `createElement` function
TypeScript
6
star
27

wordpress-exporter

WordPress model exporter for Bustle
PHP
5
star
28

broccoli-test-builder

JavaScript
4
star
29

gziptest

JavaScript
4
star
30

broccoli-multi-builder

JavaScript
4
star
31

ember-cli-image-imgix

An addon that builds on top of ember-cli-image to add imgix.com support
JavaScript
3
star
32

wool

Lambda Wrapper
JavaScript
3
star
33

mobiledoc-html-renderer

Deprecated. See https://github.com/bustlelabs/mobiledoc-dom-renderer#rendering-html
JavaScript
3
star
34

ember-mobiledoc-text-renderer

JavaScript
3
star
35

fastText-layer

fastText for AWS Lambda
Shell
3
star
36

ember-cli-image-lazy

An addon that builds on top of ember-cli-image to add lazy-loaded image support.
JavaScript
2
star
37

slugify

JavaScript
2
star
38

broccoli-amd-loader

JavaScript
2
star
39

max-socket

Prototype socket server for our internal CMS. Used for talk at Ember NYC.
JavaScript
2
star
40

apple-news-cli

A node CLI tool for publishing to Apple News
JavaScript
1
star
41

mobiledoc-jsx-renderer

TypeScript
1
star
42

s3_master

Manage S3 bucket policies without cloudformation
Ruby
1
star
43

graphql-loader

GraphQL Loader for Webpack
TypeScript
1
star
44

statsd-docker

Statsd dockerized service using elasticsearch-statsd-backend
Dockerfile
1
star
45

mobiledoc-apple-news-renderer

JavaScript
1
star