Serverless Framework 3.0

While the Serverless Framework project provides a reliable stream of small regular updates, new features have become somewhat of a rarity for the tool looking to help devs work with serverless architectures. Just out version 3.0 breaks with that trend by introducing stage parameters and a new CLI design. On top of that, they've worked on cleaning up the dependencies to make the serverless package 40% lighter and get rid of NPM security warnings. The current version support code written in Node.js, Python, Java, Go, C#, Ruby, Swift, Kotlin, PHP, Scala, and F#. Here are the main features of this new release.

Upgrading

Before we dive into the new features, let's talk about upgrading from v2 to v3.

To upgrade safely, follow these 3 steps:

  1. Upgrade to the latest v2 version (e.g. via "npm -g install serverless@2").

  2. Fix any deprecation you encounter when deploying with v2.

  3. When there are no deprecations left, you are safe to upgrade to v3:

If you installed serverless as a standalone binary, read these instructions instead.

You can read the complete "Upgrading to v3" guide to read about all breaking changes and instructions for specific cases.

It is also possible to use both v2 and v3 in different projects. Read more about this in the v3 upgrade guide.

Finally, if you are looking to get started with Serverless Framework v3, check out the new Getting Started guide.

Stage parameters

Serverless Framework v3 introduces "stage parameters". It allows changing the service configuration based on the current stage. This is particularly useful when deploying services to multiple environments, like a development/staging environment and a production environment.

Parameters can be defined under the new params key, and can be used via "${param:xxx}" variables:

In the example above, the "${param:domain}" variable will resolve to:

  • myapp.com for the "prod" stage

  • preview.myapp.com for the "dev" stage

It is also possible to define default parameter values via the default key. These values will apply to all the other stages

Finally, thanks to the optional integration with Serverless Dashboard, you can also store secret values securely and retrieve them via the "${param:my-secret}" variable syntax.

Learn everything about stage parameters in the Parameters documentation.

Redesigned CLI experience

Over the years, Serverless Framework has become the most advanced tool to create and deploy serverless applications. This comes with a challenge: maintaining a clean and simple experience for users. As deprecations, plugins, and cloud resources multiply, so does the noisiness of the CLI. The new design includes:

  • Focuses on actionable information.

  • Removes all extra noise.

  • Is easier on the eyes with minimalistic colors and styles.

Below is a preview of the new design with the most common commands.

Deploy

The "serverless deploy" command now features a clean and minimal output. Here is a comparison of v2 (left) and v3 (right):

Verbose output

Serverless Framework v3 now supports the standard "--verbose" flag to output more details.

That option can be particularly useful in CI/CD, for example to get a detailed history of the CloudFormation deployment:

Clear errors

The error screen has been improved, any failure is now clearly signaled, secondary information is toned down and the error message is printed last, to appear right above the command prompt.

On top of that, CloudFormation errors now contain more details about resources and their statuses.

New serverless onboarding

Serverless Framework can now interactively set up new projects, just run "serverless" in an empty directory and follow the prompt.

The interactive setup also lets you set up the Serverless Dashboard in a few steps. Run "serverless" in an existing project and get access to premium monitoring, AWS account management, parameters, and more.

Upgrading plugins

Fortunately, most of the plugins are compatible with v3 and integrate with the new CLI design. Some plugins might not integrate fully with the new design yet, but they should work fine.

This is why v3 comes with:

The Serverless Framework was developed to help users build and deploy web, mobile, and IoT applications on a variety of cloud services and has since been optimized for CI and CD workflows. If you need to implement serverless solutions to your project, contact us by clicking on the button below to work with our DevOps teams.

Source: serverless.com

Previous
Previous

The global cybersecurity skills gap

Next
Next

Why Git is essencial for DevOps