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
--numberor-nRequired. Number of previous versions to keep.--stageor-sThe stage to prune.--regionor-rThe region to prune.--functionor-fLimit pruning to a specific function.--layeror-lLimit pruning to a specific layer.--includeLayersor-iInclude layers in pruning.--dryRunor-dPreview what would be deleted without deleting.--verboseEnable 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