Skip to content

Code for Skooldio Serverless with AWS Lambda workshop

Notifications You must be signed in to change notification settings

roparat/skooldio-lambda

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to Serverless with AWS Lambda Workshop by Skooldio

This sample code helps you learn how to build and deploy applications to AWS Lambda using AWS Cloudformation by providing

  • A simple Express.js web service to index and search faces by calling AWS Rekoginition service
  • A Lambda function triggered by S3 file upload to analyze facial image by calling AWS Rekoginition service

Prerequisite

  • AWS CLI

Append an option --profile yourprofile for all commands to use a particular profile in your credential file

Create a new Face collection

We will need to create a new face colleciton named skooldio in Rekognition service. Run a command

$ aws rekognition create-collection --collection-id skooldio

Run locally

We will need an S3 bucket to store face images.

By default, AWS SDK will use AWS credentials from your AWS CLI. You can set AWS_PROFILE env variable to use a particular profile in your credential

$ npm install
$ node api/local.js

Use postman collection and env files in /postman to test your API.

Workshop: API

The js code for API is in /api

Workshop: S3

The js code for S3 event processing is in /s3

  • Modify s3/test.js to test the feature locally by running command
$ node s3/test.js
  • Create a Lambda handler and modify template.yml based on example

Deploy using AWS Cloudformation

First, you will need an S3 bucket for AWS Cloudformation to upload your code for deployment. To create a bucket, run following command with your own unique bucket name.

$ aws s3 mb s3://{your-code-bucket}

Then run following commands to package and deploy your CloudFormation stack. Replace {some-bucket} and {stack-name} with proper name.

$ aws cloudformation package \
         --template-file template.yml \
         --output-template-file template-export.yml \
         --s3-bucket {your-code-bucket}

$ aws cloudformation deploy \
         --template-file template-export.yml \
         --capabilities CAPABILITY_IAM \
         --stack-name {stack-name}

The template should also create an S3 bucket for you and pass a bucket name an env variable to your Lambda functions.

Delete all resources

After finishing the workshop, you can delete all the resources using following commands

$ aws rekognition delete-collection --collection-id skooldio
$ aws cloudformation delete-stack --stack-name {stack-name}
$ aws s3 rb s3://{your-code-bucket}

About

Code for Skooldio Serverless with AWS Lambda workshop

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%