All Projects → bonclay7 → Aws Amicleaner

bonclay7 / Aws Amicleaner

Licence: mit
Cleanup your old unused ami and related snapshots

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Aws Amicleaner

Serverless Iam Roles Per Function
Serverless Plugin for easily defining IAM roles per function via the use of iamRoleStatements at the function level.
Stars: ✭ 311 (-4.89%)
Mutual labels:  aws
T Vault
Simplified secrets management solution
Stars: ✭ 316 (-3.36%)
Mutual labels:  aws
Auto Tag
Automatically tag AWS resources on creation, for cost assignment
Stars: ✭ 322 (-1.53%)
Mutual labels:  aws
My Links
Knowledge seeks no man
Stars: ✭ 311 (-4.89%)
Mutual labels:  aws
Aws Lambda Graphql
Use AWS Lambda + AWS API Gateway v2 for GraphQL subscriptions over WebSocket and AWS API Gateway v1 for HTTP
Stars: ✭ 313 (-4.28%)
Mutual labels:  aws
Grant
OAuth Proxy
Stars: ✭ 3,509 (+973.09%)
Mutual labels:  aws
Amazon Rekognition Video Analyzer
A working prototype for capturing frames off of a live MJPEG video stream, identifying objects in near real-time using deep learning, and triggering actions based on an objects watch list.
Stars: ✭ 309 (-5.5%)
Mutual labels:  aws
Sdaccel examples
SDAccel Examples
Stars: ✭ 325 (-0.61%)
Mutual labels:  aws
Terraform Aws Iam
Terraform module which creates IAM resources on AWS
Stars: ✭ 314 (-3.98%)
Mutual labels:  aws
Ec2instances.info
Amazon EC2 instance comparison site
Stars: ✭ 3,619 (+1006.73%)
Mutual labels:  aws
Socket.io Chat Fargate
A demo application showing how to deploy a scalable realtime chat application powered by Socket.io, Node.js, Docker, and AWS Fargate, and deployed using a CI/CD pipeline powered by AWS CodePipeline
Stars: ✭ 312 (-4.59%)
Mutual labels:  aws
Docker Android
Android in docker solution with noVNC supported and video recording
Stars: ✭ 4,042 (+1136.09%)
Mutual labels:  aws
Aws Sdk Ruby
The official AWS SDK for Ruby.
Stars: ✭ 3,328 (+917.74%)
Mutual labels:  aws
Spotty
Training deep learning models on AWS and GCP instances
Stars: ✭ 310 (-5.2%)
Mutual labels:  aws
Dynamon
😈 Dynamon is GUI client for DynamoDB, can connect local dynamodb.
Stars: ✭ 324 (-0.92%)
Mutual labels:  aws
Aws Icons For Plantuml
PlantUML sprites, macros, and other includes for Amazon Web Services services and resources
Stars: ✭ 309 (-5.5%)
Mutual labels:  aws
Adapt
ReactJS for your infrastructure. Create and deploy full-stack apps to any infrastructure using the power of React.
Stars: ✭ 317 (-3.06%)
Mutual labels:  aws
Kube Ingress Aws Controller
Configures AWS Application Load Balancers according to Kubernetes Ingress resources
Stars: ✭ 326 (-0.31%)
Mutual labels:  aws
Aws Demos
A hands on repo with multiple demonstrations on AWS 🎓
Stars: ✭ 324 (-0.92%)
Mutual labels:  aws
Aws Serverless Workshops
Code and walkthrough labs to set up serverless applications for Wild Rydes workshops
Stars: ✭ 3,512 (+974.01%)
Mutual labels:  aws

aws-amicleaner

Cleanup your old unused ami and related snapshots

|Travis CI| |codecov.io| |pypi|

Description

This tool enables you to clean your custom Amazon Machine Images (AMI) <http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html>__ and related EBS Snapshots <http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSSnapshots.html>__.

You can either run in fetch and clean mode where the tool will retrieve all your private AMIs and EC2 instances, exclude AMIs being holded by your EC2 instances (it can be useful if you use autoscaling, and so on ...). It applies a filter based on their names or tags and a number of previous AMIs you want to keep. You can also check and delete EBS snapshots left orphaned by manual deletion of AMIs.

It can simply remove AMIs with a list of provided ids.

Prerequisites

  • awscli <http://docs.aws.amazon.com/cli/latest/userguide/installing.html>__
  • python 2.7 or 3+
  • python pip <https://pip.pypa.io/en/stable/installing/>__

This tool assumes your AWS credentials are in your environment, either with AWS credentials variables :

.. code:: bash

export AWS_DEFAULT_REGION='your region'
export AWS_ACCESS_KEY_ID='with token Access ID'
export AWS_SECRET_ACCESS_KEY='with token AWS Secret'

or with awscli :

.. code:: bash

export AWS_PROFILE=profile-name

Minimum AWS IAM permissions


To run the script properly, your ``aws`` user must have at least these
permissions in ``iam``:

.. code:: json

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "Stmt1458638250000",
                "Effect": "Allow",
                "Action": [
                    "ec2:DeleteSnapshot",
                    "ec2:DeregisterImage",
                    "ec2:DescribeImages",
                    "ec2:DescribeInstances",
                    "ec2:DescribeSnapshots",
                    "autoscaling:DescribeAutoScalingGroups",
                    "autoscaling:DescribeLaunchConfigurations"
                ],
                "Resource": [
                    "*"
                ]
            }
        ]
    }

Installation
------------

amicleaner is available on pypi and can be installed on your system with pip

From pypi
~~~~~~~~~

.. code:: bash

    [sudo] pip install aws-amicleaner

From source
~~~~~~~~~~~

You can also clone or download from github the source and install with pip

.. code:: bash

    cd aws-amicleaner/
    pip install [--user] -e .

Usage
-----


Getting help
~~~~~~~~~~~~

.. code:: bash

    amicleaner --help


Fetch and clean
~~~~~~~~~~~~~~~

Print report of groups and amis to be cleaned

.. code:: bash

    amicleaner --full-report

Keep previous number of AMIs

.. code:: bash

    amicleaner --full-report --keep-previous 10

Regroup by name or tags

.. code:: bash

    amicleaner --mapping-key tags --mapping-values role env

Exclude amis based on tag values

.. code:: bash

    amicleaner --mapping-key tags --mapping-values role env -excluded-mapping-values prod

Skip confirmation, can be useful for automation

.. code:: bash

    amicleaner -f --keep-previous 2


Activate orphan snapshots checking

.. code:: bash

amicleaner --check-orphans

Delete a list of AMIs


.. code:: bash

    amicleaner --from-ids ami-abcdef01 ami-abcdef02


.. |Travis CI| image:: https://travis-ci.org/bonclay7/aws-amicleaner.svg?branch=master
   :target: https://travis-ci.org/bonclay7/aws-amicleaner
.. |codecov.io| image:: https://codecov.io/github/bonclay7/aws-amicleaner/coverage.svg?branch=master
   :target: https://codecov.io/github/bonclay7/aws-amicleaner?branch=master
.. |pypi| image:: https://img.shields.io/pypi/v/aws-amicleaner.svg
   :target: https://pypi.python.org/pypi/aws-amicleaner


See this `blog article
<https://blog.d2si.io/2017/06/15/garbage-collecting-amazon-machine-images-ami/>`__
for more information.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].