{"id":20471744,"url":"https://github.com/signiant/task-cleanup","last_synced_at":"2026-04-19T11:34:30.411Z","repository":{"id":93381223,"uuid":"93556589","full_name":"Signiant/task-cleanup","owner":"Signiant","description":"ECS Task cleanup for one-time tasks","archived":false,"fork":false,"pushed_at":"2025-07-30T20:18:47.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-30T22:17:02.366Z","etag":null,"topics":["aws","ecs","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Signiant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-06-06T19:36:45.000Z","updated_at":"2025-07-30T20:18:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"abe55cb2-f82d-4822-af5c-3f4a4a84f4b8","html_url":"https://github.com/Signiant/task-cleanup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Signiant/task-cleanup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Signiant%2Ftask-cleanup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Signiant%2Ftask-cleanup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Signiant%2Ftask-cleanup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Signiant%2Ftask-cleanup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Signiant","download_url":"https://codeload.github.com/Signiant/task-cleanup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Signiant%2Ftask-cleanup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32005819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","ecs","hacktoberfest"],"created_at":"2024-11-15T14:17:07.830Z","updated_at":"2026-04-19T11:34:30.388Z","avatar_url":"https://github.com/Signiant.png","language":"Python","readme":"# task-cleanup\nMonitors an ECS cluster for running tasks of a particular family and cycles the tasks if the age is greater than \na given threshold\n\n# Purpose\nIt's possible for tasks running in ECS that are 'one-time' tasks, that *should* have a set lifetime to hang,\nand never get killed, thereby taking up resources on the cluster than could be used by other tasks. These tasks\nshould be stopped and removed if they are older than expected.\n\nSince manual work sucks, we've developed this solution which will kill any tasks (of the given family) if\nthe age of the task is greater than the given max-age (defaults to 48 hours).\n\nAuto-remediation FTW!\n\n# Solutions\nTwo separate solutions are provided here. You can run this in a docker container (and hence schedule it as an ECS\ntask) or you can run it as a lambda (and schedule the lambda run)\n\n## Lambda based\n\n### Usage\nThis tool was developed with the idea of it being run periodically. This can be accomplished using a lambda that\nis scheduled to be invoked on a periodic basis.\n\nIncluded here is a sample samconfig.toml file that can be filled in with appropriate values. If you would like to \noperate on more than one cluster (eg. multiple regions) then you can modify the template.yaml and add more events\nsimilar to the exiting `ScheduleUsEast1` event\n\nOnce all values have been filled in, you can build and deploy the lambda as follows:\n\n```bash\ncd lambda\nsam build \u0026\u0026 sam deploy --config-env prod --profile \u003caws_cli_profile_name\u003e\n```\n\n## Docker based\n\n### Prerequisites\n* Docker must be installed\n* Either an AWS role (if running on EC2) or an access key/secret key\n\n### Usage\n\nThe easiest way to run the tool is from docker (because docker rocks).\nYou will need to  pass in variables specific to the ECS task you want to affect\n\n```bash\ndocker pull signiant/task-cleanup\n```\n\n```bash\ndocker run \\\n   signiant/task-cleanup \\\n       --task-name-prefix one-time-task \\\n       --cluster-name test-cluster \\\n       --max-age 30\n       --region us-east-1 \\\n       --dryrun\n```\n\nIn this example, the arguments after the image name are\n\n* --task name prefix \u003cprefix for the one time tasks to monitor\u003e\n* --cluster-name \u003cECS cluster name\u003e\n* --max-age \u003cmax age of task in hours\u003e\n* --region \u003cAWS region\u003e\n* --dryrun (don't actually kill any tasks - display only)\n\nIn the above example, we query the cluster for tasks using task definitions beginning with one-time-task (done this \nway because cloudformation generated task definitions have a random suffix appended).  Once we have found the active\ntask definitons, we check the given cluster for running tasks using those task defintions that are older than the \ngiven max-age (30 hours in this case), and then stop those tasks.\n\nTo use an AWS access key/secret key rather than a role:\n\n```bash\ndocker run \\\n  -e AWS_ACCESS_KEY_ID=XXXXXX \\\n  -e AWS_SECRET_ACCESS_KEY=XXXXX \\\n  signiant/task-cleanup \\\n        --task-name-prefix one-time-task \\\n        --cluster-name test-cluster \\\n        --region us-east-1 \\\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigniant%2Ftask-cleanup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigniant%2Ftask-cleanup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigniant%2Ftask-cleanup/lists"}