GithubHelp home page GithubHelp logo

imranansari / serverless-blog-workshop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sc5/serverless-blog-workshop

0.0 2.0 0.0 72 KB

AWS -Serverless Blog Workshop 2016

Home Page: http://www.sc5.io

License: MIT License

JavaScript 100.00%

serverless-blog-workshop's Introduction

Serverless Blog Workshop by SC5

Example backend project for AWS - Serverless hackathon.

Project is compatible with Serverless v1

Step by step instructions for building the project with Serverless Framework v1.5

Setup project

  • Create the service from the sc5-serverless-boilerplate
> sls install -u https://github.com/SC5/sc5-serverless-boilerplate -n serverless-blog
> cd serverless-blog
> npm install

Set up storage (DynamoDB)

  • Un-comment Resources: and resources: in serverless.yml.
# DynamoDB Blog table for workshop
    BlogTable:
      Type: AWS::DynamoDB::Table
      DeletionPolicy: Retain
      Properties:
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
        KeySchema:
          - AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        TableName: ${self:provider.environment.TABLE_NAME}

Create function and endpoints

  • Create the function
sls create function -f posts --handler posts/index.handler
  • Register HTTP endpoints by adding the following to the function definition in serverless.yml
    events:
      - http:
          path: posts
          method: get          
          cors: true
          integration: lambda
      - http:
          path: posts
          method: posts
          cors: true
          integration: lambda
       - http:
          path: posts/{id}
          method: put
          cors: true
          integration: lambda
      - http:
          path: posts/{id}
          method: delete
          cors: true
          integration: lambda

Implement the functionality

  • Copy posts/index.js and posts/BlogStorage.js from this repo to your service (posts folder)

Deploy and test

  • Deploy the resources (and functions) using
sls deploy
  • Copy tests from test/posts.js in this repo to your service
  • Run serveless-mocha-plugin tests
sls invoke test --region us-east-1 --stage dev

Set up your blog application

  • Launch the blog application
  • Enter the service Url (https://..../posts). The service URL can be retrieved using
sls info

Enjoy, your ready to go!

Feedback

[email protected]

serverless-blog-workshop's People

Contributors

akozlov75 avatar laardee avatar mpuittinen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.