Contact Info
London Office :
Denizli Office :
Pamukkale Üniversitesi Teknoloji Geliştirme Merkezi B Blok Oda:Z17, 20070 Denizli
info@cloudnesil.com
+88 (0) 101 0000 000
Certified Kubernetes Administrator Certified Developer on Apache Cassandra

Cloud Nesil

Serverless Framework

Serverless Framework The Serverless Framework is a CLI tool that allows users to build & deploy auto-scaling, pay-per-execution, event-driven functions. Write your code, configure events to trigger your functions, then deploy & run those functions to your cloud provider via the Serverless CLI. You can create and run serverless service at the different platforms. These are aws, google cloud, azure, kubeless, spotinst, fn and cloudflare. You must decide one of these first. There are many plugins and resources in the serverless framework such as websocket, graphql, appsync, cognito, dynamodb, mongodb, appsync, bucket, tensorflow etc.
  • Serverless framework installed on your machine:

npm install -g serverless

  • Set-up your Provider Credentials:

serverless config credentials –provider aws –key your-access-key-ıd –secret your-secret-key

or

sls config credentials –provider aws –key your-access-key-ıd –secret your-secret-key

  • Create a new service:

serverless create –template aws-nodejs –path your-project-name

cd your-project-name

Available Templates :

clojurescript-gradle

clojure-gradle

nodejs

nodejs-typescript

alexa-typescript

nodejs-ecma-script

python

python3

ruby

provided

kotlin-jvm-maven

kotlin-jvm-gradle

kotlin-nodejs-gradle

groovy-gradle

java-maven

java-gradle

scala-sbt

csharp

fsharp

go

aws-go-dep

aws-go-mod

  • Deploy the service: After make the your changes on the service.yaml

serverless deploy | sls deploy

  • Cleanup: If at any point, you no longer need your service then you can remove the service from cloud

serverless remove | sls remove 

1. Services : A service is like a project. It’s where you define your Lambda Functions, the events that trigger them and any infrastructure resources they require, all in a file called serverless.yml.Each service configuration is managed in the serverless.yml file. Example: Declare a Serverless service, defining functions, events, provider, plugins, database tables, cognito ect…

2. Functions : All functions inside the service are Lambda functions.All of the Lambda functions in your serverless service can be found in serverless.yml under the functions property.

The handler property points to the file and module containing the code you want to run in your function

3. Events : Events are the things that trigger your functions to run. All events in the service are anything that can trigger an Lambda function.

4. Resources : Resources are the things that your services uses in itself infrastructures. (Db, Bucket, Cognito etc…) Using the Serverless Framework, you can define the infrastructure resources you need in serverless.yml

You must set the permissions of serverless service resources.You can make ones at the iamRoleStatements under provider in the .yml file.

5. Variables : Variables allow users to dynamically replace config values in serverless.yml config.They are especially useful when providing secrets for your service to use and when you are working with multiple stages.

6. Plugins : A Plugin is custom Javascript code that creates new or extends existing commands within the Serverless Framework.

npm install –save <custom-serverless-plugin>

Folder Structure of Serverless Project

Our serverless project start to grow in time. And for this we must determine the folder structure our serverless project. The folder structure of our serverless project is likes this.

Post a Comment

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code