• Documentation
  • Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Serverless Framework Logo

Serverless Framework

Intro
SetupUpgrading To V4ConceptsTutorialAWS CredentialsLicense Keys
DeployingPackagingBuildingTestingDev ModeServicesFunctions
OverviewHTTP (API Gateway v2)REST (API Gateway v1)ActiveMQApplication Load BalancerAlexa SkillAlexa Smart HomeCloudWatch EventCloudWatch LogCloudFrontCognito User PoolEventBridge EventIoTIoT Fleet ProvisioningKafkaKinesis & DynamoDBMSKRabbitMQS3ScheduleSNSSQSWebsocket
LayersManaged InstancesWeb Apps (Lambda Web Functions)Sandboxes (Lambda MicroVMs)MCP ServersAlertsVersion PruningDomainsIAM Function PermissionsParameters
OverviewSelf-reference serverless.ymlServerless CoreEnvironment VariablesCLI OptionsExternal YAML/JSON FilesJavascript propertiesGitDoppler
OverviewS3 ObjectsSSM Parameter Store & Secrets ManagerCloudFormation Stack Outputs
OverviewVaultTerraform State Output
ResourcesComposing ServicesDeployment BucketStateAgent SkillsPython support
OverviewRuntimeGatewayMemoryBrowserCode InterpreterDev Mode
API Gateway Proxy
OverviewGeneral ConfigurationAuthenticationAPI KeysData SourcesResolversPipeline FunctionsSubstitutionsCachingDelta SyncCustom DomainWAFCLI Commands
Deploying SAM/CFN TemplatesWorkflow Tips
OverviewCreating PluginsCLI OutputCustom CommandsCustom VariablesExtending the Configuration schemaExtending and overriding configuration
OverviewDashboardAxiom
Overviewagent docsagent inspectagent setupagent skills installagent skills list / readdeploydeploy functiondeploy listdevdiffinfoinvokeinvoke localloginlogin awslogin aws ssologsmetricspackageplugin installplugin uninstallprintprunereconcileremoverollbackrollback functionusage
OverviewConcepts
OverviewMetricsTracesTroubleshoot
OverviewNode.jsPython
OutputsProviders
OverviewBranch DeploymentsPreview DeploymentsCustom ScriptsTestingPrivate PackagesNotificationsMono ReposDeploy in your own CI/CDBest PracticesTroubleshootingFAQ
OverviewSetupToolsAWS Integration
Serverless.yml Reference
Examples and TutorialsConfiguration Validation
  1. CLI Reference
  2. Rollback Function

serverless rollback function

serverless rollback function copies the code of one of a function's published Lambda versions back to the function, without CloudFormation. Use it to undo a bad code change in one function quickly. To return the whole service, configuration included, to an earlier deployment, use serverless rollback.

serverless rollback function --function hello --function-version 3

hello is the function's name under functions in serverless.yml; take the version from serverless deploy list functions.

Options

serverless rollback function accepts these options:

OptionAliasValueDefaultRequiredDescription
--function-ffunction namenoneYesFunction to roll back, as named under functions in serverless.yml.
--function-versionstringnoneYesPublished Lambda version whose code to restore, such as 3.
--stage-sstringprovider.stage, else devNoStage of the function.
--region-rstringprovider.region, else us-east-1NoAWS Region of that stage.
--aws-profilestringprovider.profileNoAWS profile whose credentials the command uses.
--config-cfile pathserverless.ymlNoService configuration file to use.

serverless rollback function also accepts the options every command takes: --param="key=value" (repeatable), --org, --app, --verbose, --debug and --help (-h).

What serverless rollback function changes in AWS

serverless rollback function reads the given version of the function and updates the function's code ($LATEST) with that version's .zip package. For a function stored with codeStorageMode: reference, it points the function at the S3 object version that the Lambda version uses.

The command restores functions packaged as .zip files. A container image function has no code package to restore, and the command stops with TypeError: Failed to parse URL from undefined. To roll back a container image function, roll back the service with serverless rollback, or deploy the function with the earlier image.

The command changes only the code:

  • The function's configuration (memory, timeout, environment and so on) stays as it is.
  • No new Lambda version is published, and the CloudFormation stack isn't updated.
  • Aliases and event sources that target a published version keep that version.

Versions exist only for functions deployed with serverless deploy while provider.versionFunctions is true, the default. serverless deploy function publishes no versions. When the version doesn't exist, the command stops with:

Function "hello" with version "3" not found. Please check if you've deployed "hello" and version "3" is available for this function. Please check the docs for more info.

Running the command again with the same version restores the same code, so it is safe to re-run. To deploy the code from your files again, run serverless deploy; when nothing changed since the last deployment, it is skipped, so run serverless deploy --force.

Run serverless rollback function in CI

serverless rollback function has no prompts of its own. In CI, pass --stage and --region and sign in with SERVERLESS_ACCESS_KEY or SERVERLESS_LICENSE_KEY; see Non-interactive use.

Output of serverless rollback function

Rolling back function hello to version "3"

✔ Successfully rolled back function hello to version "3" (3s)

Provided lifecycle events

  • rollback:function:rollback

Examples

Find a version and restore its code

List each function's versions:

serverless deploy list functions
hello
  All Versions: $LATEST, 1, 2, 3

Restore the code of version 2:

serverless rollback function --function hello --function-version 2

Roll back a function in a specific stage

serverless rollback function -f hello --function-version 2 --stage prod --region eu-central-1

Related commands

  • serverless deploy list functions lists the versions you can restore.
  • serverless rollback returns the whole service to an earlier deployment.
  • serverless deploy function deploys one function's current code.
Edit this page
Prev rollbackNextusage

Contents

  • serverless rollback function
  • Options
  • What serverless rollback function changes in AWS
  • Run serverless rollback function in CI
  • Output of serverless rollback function
  • Provided lifecycle events
  • Examples
  • Find a version and restore its code
  • Roll back a function in a specific stage
  • Related commands

Related

GuidesPluginsExamplesSlack CommunitySupport