All Projects → TerbiumLabs → Check Reserved Instances

TerbiumLabs / Check Reserved Instances

Licence: bsd-3-clause
Compare instance reservations and running instances for AWS services

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Check Reserved Instances

Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+9600.98%)
Mutual labels:  aws, ec2, rds
Awstaghelper
AWS bulk tagging tool
Stars: ✭ 98 (-3.92%)
Mutual labels:  aws, ec2, rds
Aws Cli Cheatsheet
☁️ AWS CLI + JQ = Make life easier
Stars: ✭ 94 (-7.84%)
Mutual labels:  aws, ec2, rds
Deploy Strapi On Aws
Deploying a Strapi API on AWS (EC2 & RDS & S3)
Stars: ✭ 121 (+18.63%)
Mutual labels:  aws, ec2, rds
Aws Cost Saver
A tiny CLI tool to help save costs in development environments when you're asleep and don't need them!
Stars: ✭ 178 (+74.51%)
Mutual labels:  aws, ec2, rds
Komiser
☁️ Cloud Environment Inspector 👮🔒 💰
Stars: ✭ 2,684 (+2531.37%)
Mutual labels:  aws, ec2, rds
Ec2instances.info
Amazon EC2 instance comparison site
Stars: ✭ 3,619 (+3448.04%)
Mutual labels:  aws, ec2, rds
Ec2cryptomatic
Encrypt EBS volumes from AWS EC2 instances
Stars: ✭ 31 (-69.61%)
Mutual labels:  aws, ec2
Aws.ec2
AWS EC2 Client Package
Stars: ✭ 47 (-53.92%)
Mutual labels:  aws, ec2
Aegea
Amazon Web Services Operator Interface
Stars: ✭ 51 (-50%)
Mutual labels:  aws, ec2
Ec2 Metadata
An easy interface to query the EC2 metadata API, with caching.
Stars: ✭ 67 (-34.31%)
Mutual labels:  aws, ec2
Aws Scalable Big Blue Button Example
Demonstration of how to deploy a scalable video conference solution based on Big Blue Button
Stars: ✭ 29 (-71.57%)
Mutual labels:  aws, ec2
Jungle
AWS operations by cli should be simpler
Stars: ✭ 842 (+725.49%)
Mutual labels:  aws, ec2
Startup Kit Templates
CloudFormation templates to accelerate getting started on AWS.
Stars: ✭ 669 (+555.88%)
Mutual labels:  aws, rds
Ec2connect
Stars: ✭ 53 (-48.04%)
Mutual labels:  aws, ec2
Cloud Security Audit
A command line security audit tool for Amazon Web Services
Stars: ✭ 68 (-33.33%)
Mutual labels:  aws, ec2
Ecs Refarch Continuous Deployment
ECS Reference Architecture for creating a flexible and scalable deployment pipeline to Amazon ECS using AWS CodePipeline
Stars: ✭ 776 (+660.78%)
Mutual labels:  aws, ec2
Terraform Aws Alb
Terraform module to provision a standard ALB for HTTP/HTTP traffic
Stars: ✭ 53 (-48.04%)
Mutual labels:  aws, ec2
Aws Automation
AWS automation scripts and lambda functions
Stars: ✭ 81 (-20.59%)
Mutual labels:  aws, ec2
Content Lambda Boto3
Automating AWS with Lambda, Python, and Boto3
Stars: ✭ 91 (-10.78%)
Mutual labels:  aws, ec2

check-reserved-instances

.. image:: https://img.shields.io/travis/TerbiumLabs/check-reserved-instances.svg :target: https://travis-ci.org/TerbiumLabs/check-reserved-instances

.. image:: https://img.shields.io/coveralls/TerbiumLabs/check-reserved-instances.svg :target: https://coveralls.io/r/TerbiumLabs/check-reserved-instances

.. image:: https://img.shields.io/pypi/pyversions/check-reserved-instances.svg :target: https://pypi.python.org/pypi/check-reserved-instances/

Check Reserved Instances - Compare instance reservations with running instances

Inspired by epheph/ec2-check-reserved-instances, and pull request #5 by DavidGoodwin

Amazon’s reserved instances are a great way to save money when using EC2, RDS, ElastiCache, etc. An instance reservation is specified by an availability zone, instance type, and quantity. Correlating the reservations you currently have active with your running instances is a manual, time-consuming, and error prone process.

This quick little Python script uses boto3 to inspect your reserved instances and running instances to determine if you currently have any reserved instances which are not being used. Additionally, it will give you a list of non-reserved instances which could benefit from additional reserved instance allocations. The report may also be sent via email.

Regional Benefit Reserved Instances_ are also supported!

Installation

Install the package using pip:

::

$ pip install check_reserved_instances

Configuration

A sample configuration file is provided for easy use. By default, the script loads the configuration from config.ini in the current directory.

::

$ cp config.ini.sample config.ini

Configuring AWS Accounts/Credentials


Multiple AWS accounts/regions are supported! Specify one or many
sections with name ``[AWS <name here>]``. These are the lists of AWS
credentials that will be used to query for instances. Replace
``<name here>`` with a nickname will be provided in the report.

The following configuration options are supported:

-  **aws\_access\_key\_id** (Optional str): The AWS IAM access key for a
   specific user.
-  **aws\_secret\_access\_key** (Optional str): The AWS IAM secret key
   for a specific user.
-  **aws\_role\_arn** (Optional str): The AWS IAM role to assume to authenticate
   with if you wish to use IAM roles to authenticate across accounts.
   See `AWS Documentation`_ for more information.
-  **aws\_profile** (Optional str): The name of the `AWS CLI profile`_ to use to
   authenticate. Requires profiles to be set up via ``aws configure``.
-  **region** (Optional str): The AWS region to query for the account.
   Defaults to us-east-1. If multiple regions are desired, another
   ``[AWS <name here>]`` section is required.
-  **rds** (Optional bool): Boolean for whether or not to check RDS
   reserved instances.
-  **elasticache** (Optional bool): Whether or not to check ElastiCache
   reserved instances.

Email Report
~~~~~~~~~~~~

The report can be sent via email (SMTP). Specify a section with name
``[Email]``.

The following configuration options are supported:

-  **smtp\_host** (Required str): The hostname of the SMTP server.
-  **smtp\_port** (Optional int): The port the server uses for SMTP.
   Defaults to 25.
-  **smtp\_user** (Optional str): If your SMTP server requires
   authentication, specify a username. Defaults to None (no
   authentication).
-  **smtp\_password** (Optional str): If your SMTP server requires
   authentication, specify a password. Defaults to None (no
   authentication).
-  **smtp\_recipients** (Required str): The email addresses to send the
   email alert to. Specify one or many email addresses delimited by
   comma.

   -  Example:

      -  smtp\_recipients = [email protected]
      -  smtp\_recipients = [email protected], [email protected]

-  **smtp\_sendas** (Optional str): The email address to send the emails
   as. Defaults to ``[email protected]``.
-  **smtp\_tls** (Optional bool): Whether or not the SMTP server should
   use TLS to connect. Defaults to False.

Usage
-----

The following optional parameter is supported:

- **-–config** : Specify a custom path to the configuration file.

Ideally, this script should be ran in a cronjob:

::

    # Run on the first day of every month
    0 0 1 * * check-reserved-instances --config config.ini

For one-time use, execute the script:

::

    $ check-reserved-instances --config config.ini
    ##########################################################
    ####            Reserved Instances Report            #####
    ##########################################################

    Below is the report on EC2 VPC reserved instances:
    UNUSED RESERVATION! (1) c4.large    All     Expires in [42] days.
    UNUSED RESERVATION! (1) m1.small    us-east-1b    Expires in [201] days.
    UNUSED RESERVATION! (1) m2.2xlarge  us-east-1a    Expires in [60] days.
    NOT RESERVED!  (1) t1.micro    us-east-1c    i-sxcs34na
    NOT RESERVED!  (2) m1.small    us-east-1d    i-dfgeqa53, i-456sdf4g
    NOT RESERVED!  (3) m1.medium   us-east-1d    test_instance1, i-sdf3f4d6, test_instance2
    NOT RESERVED!  (1) m2.2xlarge  us-east-1b    i-21asdf4a

    (23) running on-demand EC2 instances
    (18) EC2 reservations


    Not sending email for this report

In this example, you can easily see that an m2.2xlarge was spun up in
the wrong AZ (us-east-1b vs. us-east-1a). A c4.large regional benefit reserved instance is also unused. The
“NOT RESERVED!” section shows that you could benefit from reserving:

-  \(1) t1.micro
-  \(1) m1.small (not 2, since you’ll likely want to move your us-east-1b small to us-east-1d)
-  \(3) m1.medium

Additionally, instance IDs or Name tags are provided for unreserved
instances, and time to expiration for unused reservations are reported.

Ignoring Reservations for Running Instances
-------------------------------------------

If you wish to ignore certain running instances when performing the calculation,
you may tag these instances as follows:

::

  Key: NoReservation
  Value: True


NOTE: This feature is currently only supported for EC2 instances.

Required IAM Permissions
------------------------

The following example IAM policy is the minimum set of permissions
needed to run the reporter:

::

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "ec2:DescribeInstances",
                    "ec2:DescribeReservedInstances",
                    "ec2:DescribeAccountAttributes",
                    "rds:DescribeDBInstances",
                    "rds:DescribeReservedDBInstances",
                    "elasticache:DescribeCacheClusters",
                    "elasticache:DescribeReservedCacheNodes"
                ],
                "Resource": "*"
            }
        ]
    }


Contributing
------------

Bug reports and pull requests are welcome. If you would like to
contribute, please create a pull request against master. Include unit
tests if necessary, and ensure that your code passes all linters (see
tox.ini).

.. _epheph/ec2-check-reserved-instances: https://github.com/epheph/ec2-check-reserved-instances
.. _pull request #5 by DavidGoodwin: https://github.com/epheph/ec2-check-reserved-instances/pull/5
.. _Regional Benefit Reserved Instances: https://aws.amazon.com/blogs/aws/ec2-reserved-instance-update-convertible-ris-and-regional-benefit/
.. _AWS Documentation: http://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_cross-account-with-roles.html
.. _AWS CLI profile: https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html
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].