Skip to content

dboytherealest1000/serverless-boilerplates

Repository files navigation

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

About

🍛 Collection of serverless boilerplates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors