Gathering detailed insights and metrics for sls-prune-plugin-v2
Gathering detailed insights and metrics for sls-prune-plugin-v2
Gathering detailed insights and metrics for sls-prune-plugin-v2
Gathering detailed insights and metrics for sls-prune-plugin-v2
Serverless Framework plugin to reap unused versions of deployed functions from AWS
npm install sls-prune-plugin-v2
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
366 Stars
117 Commits
35 Forks
9 Watchers
3 Branches
11 Contributors
Updated on Jan 21, 2025
Latest Version
2.1.1
Package Id
sls-prune-plugin-v2@2.1.1
Unpacked Size
20.62 kB
Size
6.54 kB
File Count
16
NPM Version
10.8.2
Node Version
20.17.0
Published on
Sep 10, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
4
Following deployment, the Serverless Framework does not purge previous versions of functions from AWS, so the number of deployed versions can grow out of hand rather quickly. This plugin allows pruning of all but the most recent version(s) of managed functions from AWS. This plugin is compatible with Serverless 1.x and higher.
Install with npm:
1npm install --save-dev serverless-prune-plugin
And then add the plugin to your serverless.yml
file:
1plugins: 2 - serverless-prune-plugin
Alternatively, install with the Serverless plugin command (Serverless Framework 1.22 or higher):
1sls plugin install -n serverless-prune-plugin
In the project root, run:
1sls prune -n <number of version to keep>
This will delete all but the n
-most recent versions of each function deployed. Versions referenced by an alias are automatically preserved.
A single function can be targeted for cleanup:
1sls prune -n <number of version to keep> -f helloWorld
The previous usage examples prune the default stage in the default region. Use --stage
and --region
to specify:
1sls prune -n <number of version to keep> --stage production --region eu-central-1
This plugin can also be configured to run automatically, following a deployment. Configuration of automatic pruning is within the custom
property of serverless.yml
. For example:
1custom: 2 prune: 3 automatic: true 4 number: 3
To run automatically, the automatic
property of prune
must be set to true
and the number
of versions to keep must be specified.
It is possible to set number
to 0
. In this case, the plugin will delete all the function versions (except $LATEST); this is useful when disabling function versioning for an already-deployed stack.
This plugin can also prune Lambda Layers in the same manner that it prunes functions. You can specify a Lambda Layer, or add the flag, includeLayers
:
1custom: 2 prune: 3 automatic: true 4 includeLayers: true 5 number: 3
A dry-run will preview the deletion candidates, without actually performing the pruning operations:
1sls prune -n <number of version to keep> --dryRun
See:
1sls prune --help
To run this plugin, the user will need to be allowed the following permissions in AWS:
lambda:listAliases
lambda:listVersionsByFunction
lambda:deleteFunction
lambda:listLayerVersions
lambda:deleteLayerVersion
How do I set up different pruning configurations per region/stage?
Several suggestions are available in this thread.
Can I just disable versioning entirely?
Absolutely. While Serverless Framework has it enabled by default, versioning can be disabled.
Copyright (c) 2017 Clay Gregory. See the included LICENSE for rights and limitations under the terms of the MIT license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
Found 1/9 approved changesets -- score normalized to 1
Reason
9 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More