Serverless: How is it different from Pure Lambda

Created on 24 Apr 2017  路  1Comment  路  Source: serverless/serverless

Hi! I really like the idea of building a framework over amazon lambda, though I cannot understand what is the difference between serverless framework and just using amazon's lambda API?

What are the benefits of using serverless? The quickstart does not make it obvious

question

Most helpful comment

Hey @DataGreed 馃憢

Great question. Thanks for asking.

AWS has introduced Lambda as a way to run functions / code when pre-defined events occur. This could be an API Gateway request, a new row which was added in DynamoDB or something happened in your S3 bucket.

You could use the AWS SDK, AWS CLI or the web console to setup all the necessary resources (e.g. S3 buckets, Lambda functions, DynamoDB tables, etc.) and their dependencies.

However this can be a tedious process. Let's imagine you want to use a S3 bucket which should trigger a Lambda function whenever you upload a new image (the typical "create a thumbnail example").

Here are the steps involved to setup everything:

  • Zip function code
  • Upload function code into you Lambda function (maybe even through a separate S3 bucket)
  • Setup permissions
  • Create S3 bucket for image upload
  • Setup triggers and permissions so that your Lambda function will be executed

With Serverless you define a serverless.yml which describes your setup and your function code and drop both into a directory:

# serverless.yml
service: image-transformer

provider:
  name: aws
  runtime: nodejs6.10

functions:
  imageTransformer:
    handler: handler.run
    events:
      - s3: my-images

After installing the Serverless Framework CLI tool via npm install -g serverless you simply run serverless deploy in your directory and Serverless will do its thing. It will zip your function code, create all the resources and permissions and so on and so forth.

Your service can be as complex as you want it to be. Furthermore the Serverless Framework is built with extensibility in mind. Everything is a plugin and you can build and drop in your own plugins to extend the functionality.

Provider implementations are also shipped as plugins. This way you could e.g. deploy to Azure, OpenWhisk or Google Cloud.

Definitely check out the docs, examples and plugins:

Let us know if you have any questions or need additional information.

>All comments

Hey @DataGreed 馃憢

Great question. Thanks for asking.

AWS has introduced Lambda as a way to run functions / code when pre-defined events occur. This could be an API Gateway request, a new row which was added in DynamoDB or something happened in your S3 bucket.

You could use the AWS SDK, AWS CLI or the web console to setup all the necessary resources (e.g. S3 buckets, Lambda functions, DynamoDB tables, etc.) and their dependencies.

However this can be a tedious process. Let's imagine you want to use a S3 bucket which should trigger a Lambda function whenever you upload a new image (the typical "create a thumbnail example").

Here are the steps involved to setup everything:

  • Zip function code
  • Upload function code into you Lambda function (maybe even through a separate S3 bucket)
  • Setup permissions
  • Create S3 bucket for image upload
  • Setup triggers and permissions so that your Lambda function will be executed

With Serverless you define a serverless.yml which describes your setup and your function code and drop both into a directory:

# serverless.yml
service: image-transformer

provider:
  name: aws
  runtime: nodejs6.10

functions:
  imageTransformer:
    handler: handler.run
    events:
      - s3: my-images

After installing the Serverless Framework CLI tool via npm install -g serverless you simply run serverless deploy in your directory and Serverless will do its thing. It will zip your function code, create all the resources and permissions and so on and so forth.

Your service can be as complex as you want it to be. Furthermore the Serverless Framework is built with extensibility in mind. Everything is a plugin and you can build and drop in your own plugins to extend the functionality.

Provider implementations are also shipped as plugins. This way you could e.g. deploy to Azure, OpenWhisk or Google Cloud.

Definitely check out the docs, examples and plugins:

Let us know if you have any questions or need additional information.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brendanmckenzie picture brendanmckenzie  路  3Comments

kevindiamond picture kevindiamond  路  3Comments

BarakChamo picture BarakChamo  路  3Comments

gandhi-jay picture gandhi-jay  路  3Comments

tomyam1 picture tomyam1  路  3Comments