Serverless Framework
Last updated
Last updated
Serverless Framework is open-source software that builds, compiles, and packages code for serverless deployment and then deploys the package to the cloud.
It Helps us to focus on Business Logic Rather than software and Hardware
Developers write Lambda functions, which are triggered by the client app, and user’s requests come through the API Gateway. AWS Lambda provides functions as a service
We usually wrap up our serverless script in serverless.yml
Prerequisites:
Nodejs
AWS: To run serverless commands that interface with your AWS account, you will need to setup your AWS account credentials on your machine.
To know more
In Linux Follow the Below command to install serverless-framework
Verify Installation:
The above command Will give you result similar to those below
Serverless
An average serverless.yml
will Look like the below
You can Get started with the project by generating Templates
AWS-Python:
To generate AWS-Python
Template for serverless
, Use the below Command:
The Above Command will generate below mentioned two files in MyNewService
Directory :
serverless.yml
handler.py
Similarly For JS ...
AWS-JS:
To generate AWS-NodeJS
Template for serverless
, Use the below Command:
The Above Command will generate below mentioned two files in MyNewService
Directory :
serverless.yml
handler.js
Terms in-Detail:
service
: It is simply the name of your project.
frameworkVersion
: Framework Version
resources
: We can Add CloudFormation resource templates to this
So to deploy the service to AWS, use the below Command
In order to remove a service that we've deployed, we can use Below Command
To know more about other templates
app
& org
for use with
provider
: This section includes configurations related to cloud provider
like , , GCP, etc., (We Talk about AWS Here)
You can use the package
and exclude
configuration for more control over the packaging process, to know more
functions
: Functions are AWS Lambda functions. You can find all options available on.
Permissions
: If your lambda needs to access other AWS services (S3, SQS, SNS…), you will need to add the proper permissions via the provider
>iamRoleStatements
, To know more