{"id":22201784,"url":"https://github.com/claygregory/serverless-prune-plugin","last_synced_at":"2025-04-11T23:19:58.940Z","repository":{"id":15863120,"uuid":"78903770","full_name":"claygregory/serverless-prune-plugin","owner":"claygregory","description":"Serverless Framework plugin to reap unused versions of deployed functions from AWS","archived":false,"fork":false,"pushed_at":"2025-02-18T01:04:17.000Z","size":1648,"stargazers_count":366,"open_issues_count":13,"forks_count":35,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-11T23:19:52.568Z","etag":null,"topics":["aws-lambda","serverless","serverless-framework"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/claygregory.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-14T02:05:36.000Z","updated_at":"2025-01-21T00:28:34.000Z","dependencies_parsed_at":"2024-06-18T12:35:12.605Z","dependency_job_id":"412077f5-8916-48f6-afbc-730a5c8f04d3","html_url":"https://github.com/claygregory/serverless-prune-plugin","commit_stats":{"total_commits":107,"total_committers":13,"mean_commits":8.23076923076923,"dds":0.6074766355140186,"last_synced_commit":"6f94b3c56cfc0f96823300bbaa65c7ae701d9868"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claygregory%2Fserverless-prune-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claygregory%2Fserverless-prune-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claygregory%2Fserverless-prune-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/claygregory%2Fserverless-prune-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/claygregory","download_url":"https://codeload.github.com/claygregory/serverless-prune-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492896,"owners_count":21113163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","serverless","serverless-framework"],"created_at":"2024-12-02T16:10:25.339Z","updated_at":"2025-04-11T23:19:58.918Z","avatar_url":"https://github.com/claygregory.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Serverless Prune Plugin\n\nFollowing 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.\n\n[![Serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n[![Coverage Status](https://coveralls.io/repos/github/claygregory/serverless-prune-plugin/badge.svg?branch=master)](https://coveralls.io/github/claygregory/serverless-prune-plugin?branch=master)\n\n## Installation\n\nInstall with **npm**:\n```sh\nnpm install --save-dev serverless-prune-plugin\n```\n\nAnd then add the plugin to your `serverless.yml` file:\n```yaml\nplugins:\n  - serverless-prune-plugin\n```\n\nAlternatively, install with the Serverless **plugin command** (Serverless Framework 1.22 or higher):\n```sh\nsls plugin install -n serverless-prune-plugin\n```\n\n## Usage\n\nIn the project root, run:\n```sh\nsls prune -n \u003cnumber of version to keep\u003e\n```\n\nThis will delete all but the `n`-most recent versions of each function deployed. Versions referenced by an alias are automatically preserved.\n\n### Single Function\n\nA single function can be targeted for cleanup:\n```sh\nsls prune -n \u003cnumber of version to keep\u003e -f helloWorld\n```\n\n### Region/Stage\n\nThe previous usage examples prune the default stage in the default region. Use `--stage` and `--region` to specify: \n```sh\nsls prune -n \u003cnumber of version to keep\u003e --stage production --region eu-central-1\n```\n\n### Automatic Pruning\n\nThis 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:\n\n```yaml\ncustom:\n  prune:\n    automatic: true\n    number: 3\n```\n\nTo run automatically, the `automatic` property of `prune` must be set to `true` and the `number` of versions to keep must be specified.\nIt 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.\n\n### Layers\n\nThis 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`:\n\n```yaml\ncustom:\n  prune:\n    automatic: true\n    includeLayers: true\n    number: 3\n```\n\n### Dry Run\n\nA dry-run will preview the deletion candidates, without actually performing the pruning operations:\n```sh\nsls prune -n \u003cnumber of version to keep\u003e --dryRun\n```\n\n### Additional Help\n\nSee:\n```sh\nsls prune --help\n```\n\n## Permissions Required\n\nTo run this plugin, the user will need to be allowed the following permissions in AWS:\n- `lambda:listAliases`\n- `lambda:listVersionsByFunction`\n- `lambda:deleteFunction`\n- `lambda:listLayerVersions`\n- `lambda:deleteLayerVersion`\n\n## Common Questions\n\n**How do I set up different pruning configurations per region/stage?**\n\nSeveral suggestions are available in [this thread](https://github.com/claygregory/serverless-prune-plugin/issues/21#issuecomment-622651886).\n\n**Can I just disable versioning entirely?**\n\nAbsolutely. While Serverless Framework has it enabled by default, [versioning can be disabled](https://www.serverless.com/framework/docs/providers/aws/guide/functions/#versioning-deployed-functions).\n\n## License\n\nCopyright (c) 2017 [Clay Gregory](https://claygregory.com). See the included [LICENSE](LICENSE.md) for rights and limitations under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaygregory%2Fserverless-prune-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclaygregory%2Fserverless-prune-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclaygregory%2Fserverless-prune-plugin/lists"}