{"id":15775947,"url":"https://github.com/felipelaptrin/old-lambdas-cleaner","last_synced_at":"2026-04-27T22:32:53.482Z","repository":{"id":128987344,"uuid":"583722438","full_name":"felipelaptrin/old-lambdas-cleaner","owner":"felipelaptrin","description":"AWS Lambda that puts old lambdas in a quarantine state and then deletes them","archived":false,"fork":false,"pushed_at":"2022-12-30T18:56:35.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T17:12:12.216Z","etag":null,"topics":["aws","circleci","lambda","python","serverless"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felipelaptrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-12-30T17:37:49.000Z","updated_at":"2024-02-27T13:59:15.000Z","dependencies_parsed_at":"2023-05-09T20:00:29.717Z","dependency_job_id":null,"html_url":"https://github.com/felipelaptrin/old-lambdas-cleaner","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"8f6ec1bb16387b6abfb973104fec13ee7c01c175"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/felipelaptrin/old-lambdas-cleaner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fold-lambdas-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fold-lambdas-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fold-lambdas-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fold-lambdas-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felipelaptrin","download_url":"https://codeload.github.com/felipelaptrin/old-lambdas-cleaner/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipelaptrin%2Fold-lambdas-cleaner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32358509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","circleci","lambda","python","serverless"],"created_at":"2024-10-04T17:03:55.067Z","updated_at":"2026-04-27T22:32:53.459Z","avatar_url":"https://github.com/felipelaptrin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# old-lambdas-cleaner\n\n## Description\nThe code in this repository is responsible for deactivating and deleting old Lambdas in AWS.\n\n## Architecture\n\n![The architecture of the project](/docs/architecture.png)\n\n## Environment Variables\nThe following environment variables must be used in this code:\n\n| **Environment Variable** | **Description**                                                                                            | **Example**                                                                    |\n|--------------------------|------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| AWS_REGION               | The AWS region where the AWS Lambdas were created. This is automatically passed by AWS Lambda when AWS starts the Lambda execution.       | us-west-2                                                                      |\n| ENVIRONMENT              | Name of the environment that this project will run. It accepts values: DEV, STAGING, or PROD                 | PROD                                                                           |\n| SLACK_SECRET_MANAGER_ARN | ARN of Secret Manager that contains the Slack API Token used to send Slack messages                        | `arn:aws:secretsmanager:us-east-1:111111111111:secret:slack-token-H1M3Yw`               |\n| SLACK_CHANNEL            | Name of the Slack channel that will receive the message                                                    | notification-channel                                                                    |\n| THRESHOLD_OLD_LAMBDA     | How many days since the last Lambda log event in the CloudWatch Group the Lambda will be considered as old | 180                                                                            |\n\n\n## Actions\nThis code is responsible for:\n\n1) Get information (name, last time it ran, tags...) about all Lambdas in a given region\n2) Block traffic (concurrency execution will be set to zero) to all Lambdas that are `THRESHOLD_OLD_LAMBDA` days old and mark Lambda for deletion by adding `deleteAfter` (it will be blocked for 90 days and after that, it will delete the Lambda) and `isBlockedForInactivity` tags to control the process.\n3) Send a message via Slack informing the Lambdas that were blocked and Lambdas that will be deleted soon (in 14 days).\n4) Unblocking Lambda by triggering the Lambda manually specifying the Lambda that needs to be unblocked. This will add a tag called `THRESHOLD_OLD_LAMBDA` that will increase the threshold value to two times the value of the `THRESHOLD_OLD_LAMBDA` environment variable. For example: if the environment variable `THRESHOLD_OLD_LAMBDA` is set to 180 days and the Lambda is unblocked, it will increase the `THRESHOLD_OLD_LAMBDA` of this Lambda to 360 days. If in the future it gets unblocked again it will increase the `THRESHOLD_OLD_LAMBDA` tag of this Lambda to 540 days and so on.\n\n## How to unblock a function\nWhen the latest log of a Lambda is at least `THRESHOLD_OLD_LAMBDA` days apart from today, the Lambda will be blocked (concurrent execution will be zero). After 90 days this Lambda will be deleted automatically.\n\nThere are cases where the Lambda should not be deleted and should be unblocked. In this case, the Lambda can be manually triggered.\n\n### 1) Export the Lambda function name and AWS region\n\nExample:\n```sh\nexport FUNCTION_NAME=my-important-lambda\nexport AWS_REGION=us-west-2\n```\n\n### 2) Trigger the lambda\n\n```sh\naws lambda invoke --function-name lambda-cleanup --payload \"{\\\"action\\\":\\\"unblockLambda\\\",\\\"functionName\\\":\\\"$FUNCTION_NAME\\\"}\" --region $AWS_REGION --cli-binary-format raw-in-base64-out /tmp/lambda-response.json \u003e /tmp/invoke-return.json\necho \"\\n\\nInvoke return...\"\ncat /tmp/invoke-return.json\necho \"\\nLambda response...\"\ncat /tmp/lambda-response.json\n```\n\n## Notes\n1) The code only considers Lambdas that contain a CloudWatch Group to log the events. This means that, if the Lambda was never triggered or does not log into a CloudWatch Group, it will never be detected by this code.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipelaptrin%2Fold-lambdas-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelipelaptrin%2Fold-lambdas-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipelaptrin%2Fold-lambdas-cleaner/lists"}