Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
"Serverless"	
  Express
@AnnaGerber
Before	
  you	
  start
You’ll	
  need:
• An	
  AWS	
  account	
  
• An	
  IAM	
  user	
  with	
  permissions	
  for	
  AWS...
aws-­‐serverless-­‐express
Library	
  for	
  using	
  AWS	
  Lambda	
  and	
  Amazon	
  API	
  Gateway	
  with	
  Express
...
AWS	
  Lambda
API	
  Gateway
Cloud	
  Formation
Example	
  app
AWS	
  SAM
• Serverless Application	
  Model
• JSON	
  or	
  YAML
• Defines	
  API	
  Gateway	
  APIs,	
  Lambda	
  functi...
Configure	
  the	
  Sample	
  app
Setup
npm run	
  setup
Cloud	
  Formation	
  Stack
Stack	
  Outputs
Example	
  app
DynamoDB
Persisting	
  data	
  to	
  DynamoDB
To	
  persist	
  users	
  to	
  DynamoDB:
• Add	
  DynamoDB permissions	
  to	
  the	...
Update	
  role	
  permission
Create	
  Table	
  Users
Modify	
  the	
  routes
• Add	
  the	
  AWS	
  SDK	
  for	
  DynamoDB support
• npm install	
  	
  -­‐-­‐save	
  aws-­‐sdk...
Create	
  a	
  User
List	
  Users
List	
  a	
  specific	
  User
Develop	
  your	
  API
• Continue	
  to	
  develop	
  as	
  for	
  regular	
  express	
  app
• Logs	
  for	
  the	
  app	
...
Upcoming SlideShare
Loading in …5
×

"Serverless" express

145 views

Published on

The aws-serverless-express library enables you to build web services with Node.js and Express and run them as AWS Lambda functions delivered through the Amazon API Gateway. This talk will step through how to use this library to develop a simple API backed by DyamoDB, and how to deploy it to AWS via CloudFormation.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

"Serverless" express

  1. 1. "Serverless"  Express @AnnaGerber
  2. 2. Before  you  start You’ll  need: • An  AWS  account   • An  IAM  user  with  permissions  for  AWS  Lambda,  API  Gateway,   CloudFormation,  DynamoDB,  S3  and  CloudWatch • Recent  version  AWS-­‐CLI  installed https://aws.amazon.com/cli/
  3. 3. aws-­‐serverless-­‐express Library  for  using  AWS  Lambda  and  Amazon  API  Gateway  with  Express git clone  https://github.com/awslabs/aws-­‐serverless-­‐express See  example directory  for  sample  app
  4. 4. AWS  Lambda
  5. 5. API  Gateway
  6. 6. Cloud  Formation
  7. 7. Example  app
  8. 8. AWS  SAM • Serverless Application  Model • JSON  or  YAML • Defines  API  Gateway  APIs,  Lambda  functions,  DynamoDB tables
  9. 9. Configure  the  Sample  app
  10. 10. Setup npm run  setup
  11. 11. Cloud  Formation  Stack
  12. 12. Stack  Outputs
  13. 13. Example  app
  14. 14. DynamoDB
  15. 15. Persisting  data  to  DynamoDB To  persist  users  to  DynamoDB: • Add  DynamoDB permissions  to  the  role • Create  DynamoDB table  for  storing  users • Modify  the  CRUD  routes  in  our  Express  app  to  use  DynamoDB instead   of  in-­‐memory  array
  16. 16. Update  role  permission
  17. 17. Create  Table  Users
  18. 18. Modify  the  routes • Add  the  AWS  SDK  for  DynamoDB support • npm install    -­‐-­‐save  aws-­‐sdk var AWS  =  require("aws-­‐sdk") var docClient =  new  AWS.DynamoDB.DocumentClient()
  19. 19. Create  a  User
  20. 20. List  Users
  21. 21. List  a  specific  User
  22. 22. Develop  your  API • Continue  to  develop  as  for  regular  express  app • Logs  for  the  app  can  be  accessed  via  CloudWatch • Edit  package.json to  ensure  additional  resources  are  packaged • To  re-­‐package  and  re-­‐deploy  the  app: • npm run  package-­‐deploy • To  tear  down: • npm run  delete-­‐stack

×