GithubHelp home page GithubHelp logo

dboytherealest1000 / serverless-boilerplates Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 248 KB

πŸ› Collection of serverless boilerplates

Home Page: http://bit.ly/1Tqcwn7

License: MIT License

JavaScript 62.30% Shell 22.78% TypeScript 14.93%

serverless-boilerplates's Introduction

Serverless Boilerplates

Contents

  1. Prerequisites
  2. Setup
  3. IAM Credentials, Roles, and Permissions
  4. Development
    1. Invoke Locally
    2. Developing with tests
    3. With Localhost HTTP
    4. Locally Invoke in Docker
  5. Deployment
  6. Invocation
  7. Logs
  8. How-to
    1. Step Functions

Prerequisites

You will need:

  • An AWS IAM user account included in the arn:aws:iam::000000000000:role/aws-lambda-basic-execution-role role.
    • The account must have MFA enabled
  • You will need AWS Vault

Setup

Clone it. Yarn it.

yarn

Then, make sure to change the service name in serverless.yml.

IAM Credentials, Roles, and Permissions

Yah. You need those.

@TODO

Any commands which interact with AWS APIs assume your IAM credentials are stored in AWS Vault, and that the profile is called allthingsβ€”ideally with MFA enabled.

@TODO: expand on this.

You will need to add the following to your ~/.aws/config file. Create it, if it does not exist.

[profile allthings]
region = eu-west-1
mfa_serial = arn:aws:iam::000000000000:mfa/your.username

Development

Invoke Locally:

yarn invoke:local myFunctionName --path event-mocks/scheduled-event.json

or

yarn invoke:local myFunctionName --data '{"some": "eventData"}'

Developing with tests

yarn watch:test

Then, develop and run code via tests. See src/handler.js and src/handler.test.js for examples.

You can also run the full test suite with coverage report:

yarn test

With Localhost HTTP

yarn dev:offline

Uses serverless-offline

Locally Invoke in Docker

yarn test:docker handler.hello '{"some": "eventData"}'

Uses docker-lambda. Can also be used in tests:

import dockerLambda from 'docker-lambda'

const lambdaCallbackResult = dockerLambda({
  event: { some: 'event' },
  taskDir: __dirname,
  dockerImage: 'lambci/lambda:nodejs6.10',
})

Deployment

Deploy entire service with all functions:

yarn deploy

Invocation

To manually invoke the deployed function from your terminal:

yarn invoke myFunctionName --path event-mocks/scheduled-event.json

or

yarn invoke myFunctionName --data '{"some": "eventData"}'

Logs

See logs for a function from CloudWatch in your terminal:

yarn logs myFunctionName

serverless-boilerplates's People

Contributors

adieuadieu avatar

Watchers

 avatar  avatar

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.