{"id":13563686,"url":"https://github.com/bonclay7/aws-amicleaner","last_synced_at":"2025-05-16T13:05:57.516Z","repository":{"id":40625856,"uuid":"53578815","full_name":"bonclay7/aws-amicleaner","owner":"bonclay7","description":"Cleanup your old unused ami and related snapshots","archived":false,"fork":false,"pushed_at":"2023-11-20T16:08:52.000Z","size":111,"stargazers_count":364,"open_issues_count":31,"forks_count":131,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-10T15:03:00.934Z","etag":null,"topics":["aws","python"],"latest_commit_sha":null,"homepage":null,"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/bonclay7.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","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}},"created_at":"2016-03-10T11:21:04.000Z","updated_at":"2025-05-04T15:27:40.000Z","dependencies_parsed_at":"2024-01-15T16:46:04.833Z","dependency_job_id":null,"html_url":"https://github.com/bonclay7/aws-amicleaner","commit_stats":{"total_commits":113,"total_committers":10,"mean_commits":11.3,"dds":"0.21238938053097345","last_synced_commit":"d28c2aeba103d3403b4f1f340cc93989c929d0f5"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonclay7%2Faws-amicleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonclay7%2Faws-amicleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonclay7%2Faws-amicleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonclay7%2Faws-amicleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bonclay7","download_url":"https://codeload.github.com/bonclay7/aws-amicleaner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535827,"owners_count":22087399,"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","python"],"created_at":"2024-08-01T13:01:22.246Z","updated_at":"2025-05-16T13:05:57.496Z","avatar_url":"https://github.com/bonclay7.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"aws-amicleaner\n==============\n\nCleanup your old unused ami and related snapshots\n\n|Travis CI| |codecov.io| |pypi|\n\n\nMaintenance note\n----------------\nThis project is not under active maintenance but still active. \nConsider using the official AWS-supported `Amazon Data Lifecycle Manager\n\u003chttps://docs.aws.amazon.com/AWSEC2/latest/UserGuide/snapshot-lifecycle.html\u003e`__.\n\nDescription\n-----------\n\nThis tool enables you to clean your custom `Amazon Machine Images (AMI)\n\u003chttps://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html\u003e`__ and\nrelated `EBS Snapshots\n\u003chttps://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSSnapshots.html\u003e`__.\n\nYou can either run in ``fetch and clean`` mode where the tool will\nretrieve all your private **AMIs** and EC2 instances, exclude AMIs being\nholded by your EC2 instances (it can be useful if you use autoscaling,\nand so on ...). It applies a filter based on their **names** or **tags**\nand a number of **previous AMIs** you want to keep. You can also check and\ndelete EBS snapshots left orphaned by manual deletion of AMIs.\n\nIt can simply remove AMIs with a list of provided ids.\n\nPrerequisites\n-------------\n\n-  `awscli \u003chttp://docs.aws.amazon.com/cli/latest/userguide/installing.html\u003e`__\n-  `python 2.7 or 3+`\n-  `python pip \u003chttps://pip.pypa.io/en/stable/installing/\u003e`__\n\nThis tool assumes your AWS credentials are in your environment, either with AWS\ncredentials variables :\n\n.. code:: bash\n\n    export AWS_DEFAULT_REGION='your region'\n    export AWS_ACCESS_KEY_ID='with token Access ID'\n    export AWS_SECRET_ACCESS_KEY='with token AWS Secret'\n\nor with ``awscli`` :\n\n.. code:: bash\n\n    export AWS_PROFILE=profile-name\n\nMinimum AWS IAM permissions\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTo run the script properly, your ``aws`` user must have at least these\npermissions in ``iam``:\n\n.. code:: json\n\n    {\n        \"Version\": \"2012-10-17\",\n        \"Statement\": [\n            {\n                \"Sid\": \"Stmt1458638250000\",\n                \"Effect\": \"Allow\",\n                \"Action\": [\n                    \"ec2:DeleteSnapshot\",\n                    \"ec2:DeregisterImage\",\n                    \"ec2:DescribeImages\",\n                    \"ec2:DescribeInstances\",\n                    \"ec2:DescribeSnapshots\",\n                    \"autoscaling:DescribeAutoScalingGroups\",\n                    \"autoscaling:DescribeLaunchConfigurations\"\n                ],\n                \"Resource\": [\n                    \"*\"\n                ]\n            }\n        ]\n    }\n\nInstallation\n------------\n\namicleaner is available on pypi and can be installed on your system with pip\n\nFrom pypi\n~~~~~~~~~\n\n.. code:: bash\n\n    [sudo] pip install aws-amicleaner\n\nFrom source\n~~~~~~~~~~~\n\nYou can also clone or download from github the source and install with pip\n\n.. code:: bash\n\n    cd aws-amicleaner/\n    pip install [--user] -e .\n\nUsage\n-----\n\n\nGetting help\n~~~~~~~~~~~~\n\n.. code:: bash\n\n    amicleaner --help\n\n\nFetch and clean\n~~~~~~~~~~~~~~~\n\nPrint report of groups and amis to be cleaned\n\n.. code:: bash\n\n    amicleaner --full-report\n\nKeep previous number of AMIs\n\n.. code:: bash\n\n    amicleaner --full-report --keep-previous 10\n\nRegroup by name or tags\n\n.. code:: bash\n\n    amicleaner --mapping-key tags --mapping-values role env\n\nExclude amis based on tag values\n\n.. code:: bash\n\n    amicleaner --mapping-key tags --mapping-values role env -excluded-mapping-values prod\n\nSkip confirmation, can be useful for automation\n\n.. code:: bash\n\n    amicleaner -f --keep-previous 2\n\n\nActivate orphan snapshots checking\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: bash\n\n    amicleaner --check-orphans\n\n\nDelete a list of AMIs\n~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: bash\n\n    amicleaner --from-ids ami-abcdef01 ami-abcdef02\n\n\n.. |Travis CI| image:: https://travis-ci.org/bonclay7/aws-amicleaner.svg?branch=master\n   :target: https://travis-ci.org/bonclay7/aws-amicleaner\n.. |codecov.io| image:: https://codecov.io/github/bonclay7/aws-amicleaner/coverage.svg?branch=master\n   :target: https://codecov.io/github/bonclay7/aws-amicleaner?branch=master\n.. |pypi| image:: https://img.shields.io/pypi/v/aws-amicleaner.svg\n   :target: https://pypi.python.org/pypi/aws-amicleaner\n\n\nSee this `blog article\n\u003chttps://blog.d2si.io/2017/06/15/garbage-collecting-amazon-machine-images-ami/\u003e`__\nfor more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbonclay7%2Faws-amicleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbonclay7%2Faws-amicleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbonclay7%2Faws-amicleaner/lists"}