serverless
Deploy and manage serverless applications
TLDR
Create a serverless project
Create a serverless project from a template
Deploy to a cloud provider
Display information about a serverless project
Invoke a deployed function
Follow the logs for a project
SYNOPSIS
serverless <command> [options]
sls <command> [options] (alias)
PARAMETERS
create
Creates a new serverless service, often from a template.
deploy
Deploys the service to the configured cloud provider.
invoke
Invokes a deployed function, optionally with test data.
logs
Fetches logs for a specific function.
remove
Removes the deployed service and its resources from the cloud.
info
Displays information about the deployed service.
package
Packages the service into a deployable artifact without actually deploying it.
plugin
Manages Serverless Framework plugins (install, uninstall, etc.).
print
Prints the compiled serverless.yml, useful for debugging.
--stage <stageName>
Specifies the deployment stage (e.g., dev, prod).
--region <regionName>
Specifies the cloud region (e.g., us-east-1).
--verbose
Shows verbose output for more detailed information.
--help
Displays help information for the command or specific subcommand.
DESCRIPTION
The serverless command-line interface (CLI) is the primary tool for interacting with the Serverless Framework. This framework enables developers to build, deploy, and manage serverless applications on various cloud providers like AWS Lambda, Google Cloud Functions, Azure Functions, and others. It abstracts away complex infrastructure configurations, allowing developers to focus solely on their application code.
The CLI provides commands for scaffolding new projects, deploying functions and resources, invoking functions, viewing logs, managing stages, and removing deployed services, significantly streamlining the serverless development workflow. It integrates with cloud provider APIs to automate the provisioning and management of compute, database, and API gateway resources.
CAVEATS
Not a standard Linux utility: The serverless command is part of the Serverless Framework, which must be installed globally via npm (Node Package Manager). It is not pre-installed on Linux distributions.
Requires Node.js: The framework is built on Node.js, so a Node.js runtime environment must be present on the system.
Cloud Provider Accounts: Requires valid credentials and configurations for cloud providers (e.g., AWS, GCP, Azure) to deploy and manage resources.
Configuration File: Relies heavily on a serverless.yml configuration file within the service directory to define functions, events, and resources.
SERVERLESS.YML
This is the core configuration file for any Serverless Framework service. It defines functions, events that trigger them, cloud resources, plugins, and deployment settings. Understanding its structure and syntax is fundamental to effectively using the serverless command and framework.
PLUGINS
The Serverless Framework's functionality can be extended significantly through a rich ecosystem of plugins. These are npm packages that add new commands, modify existing behavior, or integrate with other tools (e.g., serverless-offline for local development, serverless-webpack for bundling code).
HISTORY
The Serverless Framework was launched in 2015 (originally as JAWS) by Austen Collins, coinciding with the rapid rise of serverless computing paradigms, particularly AWS Lambda. It quickly gained traction as a pivotal tool for simplifying the deployment and management of serverless applications, abstracting away much of the underlying infrastructure complexity. Its open-source nature and extensibility through a vibrant plugin ecosystem have fostered its widespread adoption and continuous development within the cloud-native community. The framework significantly contributed to popularizing the 'serverless' architectural style.