12/08/2018, 13:39

Serverless Framework1.0 has just released, let''s give it a try

Overview http://blog.serverless.com/serverless-v1-0-alpha1-announcement/ The application Serverless Framework 1.0 ALPHA version has been released so i want to have a grasp over it Install Let's install via command line like this $ npm install - g serverless @alpha If you get this ...

Overview

26dc9ce7-2b3b-d1a9-9e3e-293c78c30f3a.png

http://blog.serverless.com/serverless-v1-0-alpha1-announcement/

The application Serverless Framework 1.0 ALPHA version has been released so i want to have a grasp over it

Install

Let's install via command line like this

$ npm install -g serverless@alpha

If you get this help displayed that means your installation has been completed

$ serverless -h

Setup

Let's define our service via command line like following:

$ serverless create --name first-service --provider aws

This version is devided from the version 0 by project, first-service can be modified. This related to the limitation of naming of S3 Global, the referencing issue:

https://github.com/serverless/serverless/issues/1458

Let's take a look at our structure of service's directory, how simple it is:

Moreover, JSON is replaced by yaml

├── handler.js
├── serverless.env.yaml
└── serverless.yaml

Use of the above files:

・handler.js:Lambda: Entity of Function

・serverless.env.yaml: Overall settings of service environment, such as Region and storage

・serverless.yaml: Set to use cloud resources

Setup API Gateway + Lambda

Let's set the serverless.yaml as following: (we set to call the GET method to get the Lambda function hello via https://<API Gateway endpoint>/dev/hello)

It is short, itsn't it?

#serverless.yaml
service: horike-service
provider: aws
functions:
    hello:
        handler: handler.hello
        events:
            - http:
                path: hello
                method: GET

After that, we deploy onto AWS:

$ serverless deploy

When you access to the API you have just deployed by using the following curl, your result of Lambda function has returned flawlessly:

$curl https://ctlje3drz2.execute-api.us-east-1.amazonaws.com/dev/hello
{"message":"Go Serverless v1.0! Your function executed successfully!"}

Conclusion

I have introduced to you guys the Serverless Framework 1.0,

Regarding the biggest change, for my opinion is that we no more have to do all the complex setup for the API Gateway, we also probably don't have to remember all the setup files.

By the way, 1.0 version can not only be applied on AWS but also Google Cloud Functions, Microsoft Azure, IBM OpenWhisk, this can be more interesting further on!

0