Skip to content

Instantly share code, notes, and snippets.

@topiaruss
Last active December 19, 2016 15:26
Show Gist options
  • Save topiaruss/bf99038f90c5decf6bb7322b4867f4bc to your computer and use it in GitHub Desktop.
Save topiaruss/bf99038f90c5decf6bb7322b4867f4bc to your computer and use it in GitHub Desktop.
Colour Lambda API spike - Initial setup

Goal

Create a Lambda service that returns a list of colours

Plan

Basics

User serverless.com video and reference material, and for this initial task prefer the Node.js option.

MVP will be a tested deployment to an AWS Gateway API for demo consumption

##Later Consider

  • deployment within org's AWS infra, IAMs, etc.
  • Correlation ID passthrough
  • Logging integration

Setup

$ brew install node $ node -v v7.2.1 $ npm install serverless -g /usr/local/Cellar/node/7.2.1/bin/serverless -> /usr/local/Cellar/node/7.2.1/lib/node_modules/serverless/bin/serverless /usr/local/Cellar/node/7.2.1/bin/slss -> /usr/local/Cellar/node/7.2.1/lib/node_modules/serverless/bin/serverless /usr/local/Cellar/node/7.2.1/bin/sls -> /usr/local/Cellar/node/7.2.1/lib/node_modules/serverless/bin/serverless serverless@1.4.0 /usr/local/Cellar/node/7.2.1/lib/node_modules/serverless ��� strip-outer@1.0.0 ��� lowercase-keys@1.0.0 ... scads of deps

Adjust $PATH in ~/.bash_profile

$ serverless create -t aws-nodejs

make a few small changes to the serverless.yml file

$ serverless deploy -r eu-west-1 -s dev

go to AWS Lamba console to see the function, and execute it with a boilerplate Json snippet.

Setting up an API gateway to allow curl invokation

In the console, add a Trigger

Select API gateway

Return correct colours

Edit the JS

$ serverless deploy -r eu-west-1 -s dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment