The Serverless framework gave Serverless its name, so I wanted to take a closer look at what it provides, and how it contributed to where we are today.
The framework is downloadable from serverless.com and provides a command line interface (CLI) for creating and manipulating serverless functions.
It works with:
- Amazon AWS
- Microsoft Azure
- IBM OpenWhisk
- Google Cloud Platform
- Auth0 Webtasks
It ships as an NPM package and relies on NodeJS v6.5.o or greater. The basic framework is installed via
npm install -g serverless and then you add the vendor-specific extension packages (such as
npm install -g serverless-azure-functions for Azure). At the time of writing the latest version is 1.26.1, and like a lot of NPM packages, it pulls in quite a screenful of dependencies.
The interface runs under Node so should work where-ever Node runs, so you’re covered on Windows, Mac, and Linux.
Functions can be created by the CLI using templates. If you look at the help you get a complete list of available out-of-the-box templates:
Available templates: "aws-nodejs", "aws-nodejs-typescript", "aws-nodejs-ecma-script", "aws-python", "aws-python3", "aws-groovy-gradle", "aws-java-maven", "aws-java-gradle", "aws-kotlin-jvm-maven", "aws-kotlin-jvm-gradle", "aws-kotlin-nodejs-gradle", "aws-scala-sbt", "aws-csharp", "aws-fsharp", "aws-go", "aws-go-dep", "azure-nodejs", "google-nodejs", "kubeless-python", "kubeless-nodejs", "openwhisk-nodejs", "openwhisk-php", "openwhisk-python", "openwhisk-swift", "spotinst-nodejs", "spotinst-python", "spotinst-ruby", "spotinst-java8", "webtasks-nodejs", "plugin" and "hello-world"
You can also pull existing services straight from Github and modify those instead of creating them from scratch.
serverless deployfor the first time, you will be prompted to log in interactively, then your details are stored in a credential for subsequent use.
The framework comes with a large plugin repository to integrate with a variety of different services and call out to various utilities as part of the deployment process.
You can either deploy your entire service with a straightforward
serverless deploy command, or deploy individual functions which is useful for small incremental changes. Because your configuration is also stored as code, you get repeatable deployments as well as cross-compatibility.
The serverless framework provides a useful layer above the cloud vendor’s implementation, abstracting away differences and making your code more portable. Although the decision to change between cloud vendors isn’t taken lightly or often, it’s good to know that it can be done without major upheaval. This does of course depend on the other services you may be utilising, such as blob storage, databases, and queueing systems. The serverless space is still young, but projects such as this help move the state-of-the-art forward. We’ll never get Microsoft and Amazon to agree on a common interface so we’re always going to need abstractions like this.