• 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
DeployingPackagingBuildingTestingServicesFunctions
OverviewHTTP (API Gateway v2)REST (API Gateway v1)ActiveMQApplication Load BalancerAlexa SkillAlexa Smart HomeCloudWatch EventCloudWatch LogCloudFrontCognito User PoolEventBridge EventIoTIoT Fleet ProvisioningKafkaKinesis & DynamoDBMSKRabbitMQS3ScheduleSNSSQSWebsocket
LayersManaged InstancesAlertsVersion 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 BucketStatePython support
OverviewRuntimeGatewayMemoryBrowserCode InterpreterDev Mode
API Gateway Proxy
OverviewGeneral ConfigurationAuthenticationAPI KeysData SourcesResolversPipeline FunctionsCachingDelta SyncCustom DomainWAFCLI Commands
Deploying SAM/CFN TemplatesWorkflow Tips
OverviewCreating PluginsCLI OutputCustom CommandsCustom VariablesExtending the Configuration schemaExtending and overriding configuration
OverviewDashboardAxiom
Overviewdeploydeploy functiondeploy listdevdiffinfoinvokeinvoke localloginlogin awslogin aws ssologsmetricspackageplugin installplugin uninstallprintprunereconcileremoverollbackrollback functionsupportusage
Overview
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. Prune

AWS - Prune

The prune command removes old versions of deployed Lambda functions and layers, keeping only the specified number of most recent versions.

serverless prune -n <number>

Options

  • --number or -n Required. Number of previous versions to keep.
  • --stage or -s The stage to prune.
  • --region or -r The region to prune.
  • --function or -f Limit pruning to a specific function.
  • --layer or -l Limit pruning to a specific layer.
  • --includeLayers or -i Include layers in pruning.
  • --dryRun or -d Preview what would be deleted without deleting.
  • --verbose Enable detailed output.

Provided lifecycle events

  • prune:prune

Examples

Keep 3 most recent versions

serverless prune -n 3

Dry-run to preview deletions

serverless prune -n 3 --dryRun --verbose

Prune a specific function

serverless prune -n 5 -f myFunction

Prune including layers

serverless prune -n 3 --includeLayers

Prune only a specific layer

serverless prune -n 3 -l myLayer
Edit this page
Prev printNextreconcile

Contents

  • AWS - Prune
  • Options
  • Provided lifecycle events
  • Examples
  • Keep 3 most recent versions
  • Dry-run to preview deletions
  • Prune a specific function
  • Prune including layers
  • Prune only a specific layer

Related

GuidesPluginsExamplesSlack CommunitySupport