Serverless Framework - introduction

Entering the world of Serverless and FaaS (Function-as-a-Service) solutions, we can feel the WOW effect. Especially if we previously worked with complex platforms, the implementation of which required the coordinated work of many teams. How is it possible that now I can implement my piece of code and with a few clicks or commands it will be publicly available? I don’t have to configure any virtual or networks anymore? Oh yes! The implementation of a simple virtual function to the cloud actually seems very easy. But it is also not much more difficult to implement a classic server application on a VM in the cloud. Everything here comes down to the scale of the project. The implementation of a complex system based on e.g. the Lambda function may turn out to be equally difficult, if not more so. Many modern systems based on microservice architecture consist of tens or even hundreds of loosely connected services. The same function-based system would probably be even more granular, possibly consisting of thousands of functions. Are you still just as optimistic when you think about implementing a small functionality in such a system? You can probably already imagine the chaos in managing such a large functional codebase. Fortunately, it doesn’t have to be all that dramatic. Along with the development of FaaS solutions, a tool supporting the creation of platforms based on this model began to appear on the market. One of such tools is Serverless Framework.

In this blog post, I would like to introduce you to this tool without going into too much detail (we will talk about the details in the next articles in this series). We will briefly discuss what the Serverless Framework is and what possibilities it gives us, developers

What is Serverless Framework?

A Serverless Framework is an open-source tool providing CLI with which we can configure, build, and deploy our serverless functions. The Serverless Framework provides a standardized way of organizing our functions and the cloud services they use. Using the Serverless Framework, we are able to define the configuration of our functions and resources such as databases or storage, and then, with one command, create serverless infrastructure in the cloud and install our functional code on top of it.

It sounds a bit abstract, but it is. Serverless Framework provides just such a layer of abstraction, thanks to which we can conveniently manage the life cycle of our serverless platform. It is worth noting that this tool is based on the cloud-agnostic approach. This means that it is not strongly tied to any particular cloud provider. We can use this framework to manage FaaS such as AWS Lambda, Google Cloud Functions, Azure Functions, and many other more niche solutions.

Infrastructure as Code with Serverless Framework

Infrastructure as a Code is a popular approach/paradigm especially in the field of cloud. The assumption of IaC is to define the infrastructure in the form of code or configuration files. What is the purpose of this? First, we have the option of versioning our infrastructure using the version-control system. Thanks to this, we can have a full history of infrastructure changes in the code repository, and thus we have the ability to restore the state of the infrastructure at any moment in time. Needless to say, the version control system also allows us to collaborate on infrastructure code with other team members.

Another advantage of using IaC is the seamless replication of the environment. We can easily make copies of our environments endlessly. This makes it easy to create and maintain development and test environments that perfectly reflect the production environment. In this case, this approach also improves the implementation of changes and testing of our infrastructure.

In the Serverless Framework, the infrastructure is defined in the serverless.yml file. This file is converted to the native IaC solution of the given cloud provider. In the case of AWS, this is CloudFormation. In AWS, we are able to define quite a lot of resources using SF, including DynamoDb, bucket S3, Cognito Identity Pool, API Gateway, and of course the Lambda itself. In the case of other cloud vendors, unfortunately, we do haven’t such a large possibility of defining resources. However, Serverless Framework is being developed successively, so this may change in the future.

Serverless Framework is not a full-fledged tool for building infrastructure in the Cloud. The list of components that we can define with this tool is limited to services directly related to FaaS services. Nevertheless, SF can be a great complement to more extensive tools such as Terraform or native IaC services of a cloud provider.

Development and daily work with Serverless Framework

When it comes to everyday work with functions, Serverless Framework can make the developer’s life much easier. Manual uploading of every code change to the cloud would be a chore. Fortunately, thanks to CLI from SF, we have the opportunity to do it in a very fast and simple way. Code upgrade for example Lambda in a specific environment can be limited to the execution of a single command. Of course, in a mature production system, you probably won’t be deploying code from your local computer. The deployment pipeline will be a much better place to execute such a command

But the possibilities don’t end there. Using the Serverless Framework, we can run our function locally and test it. A hot-reload of code is also available here. All this is due to the serverless-offline plugin, which is being developed by the community related to Serverless Framework. At the moment, such a plugin is only available for AWS.

Are you considering using other services such as S3 or DynamoDB locally? Well, we are also able to emulate these services locally. All this is due to the rich repository of plugins for Serverless Framework. The community around this tool is very active, which is a big advantage of this tool. Check for yourself how many solutions are available as extensions to the Serverless Framework


So much for the introduction. I hope you got some encouragement to test this tool. In the next articles in this series, I will guide you through the full configuration of working with AWS, and finally, we will analyze a sample project showing the basic possibilities offered by Serverless Framework.

Developer, Engineer, and Cloud Enthusiastic. AWS, GCP, and K8S certified. Polish home page: