cintiadr / sample-lambda-app

Lambda + API gateway sample

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hello world - Serverless edition

Build Status

This repository contains an AWS lambda + API gateway hello world application.

It's using awesome Serverless framework to deploy (almost) all infrastructure needed.

That's the most scalable hello world I've ever created.

You cannot have outages if you don't have servers

Memetic Poetic Licence, not actually true

Development environment

Production environment

Requirements

AWS requirements(conf.json):

  • ACM Certificate
  • Route53 DNS zone

Local requirements:

  • AWS cli and credentials to deploy
  • Node 10.x (can be via nvm use)
  • ./scripts/install.sh to install all dependencies

Deploying changes

# Build cloudformation for dev
$ ENVIRONMENT=dev npm run package

# Deploying to dev
$ ENVIRONMENT=dev npm run deploy

# Running smoke tests against dev
$ ENVIRONMENT=dev npm run smoke-tests

Travis is configured to deploy branch production to the production environment. This branch should be pushed locally.

(Yes, technically this breaks the whole concept of a proper pipeline, but that's the way travis works.)

$ ./scripts/push-prd.sh

Considerations

  • This code is in node due to the better integration with serverless framework, but I'm not a node expert. Take my code with a pinch of salt;
  • Lambda is running outside VPC; security considerations apply if your lambda handles sensitive data;
  • Memory size and timeout are not being configured;
  • Environment variables are not encrypted, same security considerations;
  • There's no dashboards nor alarms for failures. Also, no dead letter queue configured for failures, nor AWS Xray.
  • There's no de-duplication mechanism for lambda because they are not changing state. Check this blogpost for details;
  • Logs and basic metrics are automatically deployed to cloudwatch by default;
  • There are no unit nor integration tests because the hello world is very basic, but you should check Serverless Testing guide if your lambda is more complex than that. Serverless offers a lot of help for local tests and debugging;
  • Smoke tests are done using Jasmine framework;

About

Lambda + API gateway sample


Languages

Language:JavaScript 83.0%Language:Shell 17.0%