GithubHelp home page GithubHelp logo

instance-list's Introduction

Description

This is a simple python script to list and sort your EC2 instances.

Prerequisites

Make sure you have python and pip installed on the server. For ubuntu run

apt-get install -y python2.7 python-pip

On Mac you should install homebrew and then run

sudo brew install python && sudo easy_install pip

Installation and Setup

Once you have python installed, clone the respository to your local machine and update the setup.sh file by replacing 'YOURKEY' and 'YOURSECRET' with your AWS access id and secret key respectively.

export AWS_ACCESS_KEY_ID='YOURKEY'
export AWS_ACCESS_SECRET_KEY='YOURSECRET'

Now simply run source ./setup.sh and the script will install and setup a virtualenv and download the script requirements.

Usage

The script options can be viewed using ./instances.py -h

usage: instances.py [-h] [--region REGION] [--order-by ORDER_BY]
                    [--fields FIELDS]
                    command

positional arguments:
  command              Commands {list}

optional arguments:
  -h, --help           show this help message and exit
  --region REGION      Set the region to get instances from
  --order-by ORDER_BY  Which field should be used to order results, must be in
                       the list of fields
  --fields FIELDS      Specify fields to return in a comma seperated list.

The only command currently available is the list command. To run it simply run ./instances.py list

Checking region us-west-2
+---------------------+---------+---------------------------+--------------+
| InstanceId          | Owner   | LaunchTime                | InstanceType |
+---------------------+---------+---------------------------+--------------+
| i-00007089efb1c5551 | Jim     | 2016-06-22 01:02:28+00:00 | t2.nano      |
| i-0bfc55c0abba070bd | Mark    | 2016-06-22 01:02:28+00:00 | t2.nano      |
| i-0815cf4ac3811ef04 | Unknown | 2016-06-22 01:02:28+00:00 | t2.nano      |
| i-0cb0e38cdd63d9692 | Unknown | 2016-06-22 01:02:28+00:00 | t2.nano      |
+---------------------+---------+---------------------------+--------------+

By default the script sorts by the "Owner" tag if it is present. You may include other tags/fields using the --field option and change the order using --order-by. For instance:

(env) $ ./instances.py list --fields=Name --order-by=Name

Checking region us-west-2
+---------------------+---------+---------------------------+--------------+---------------+
| InstanceId          | Owner   | LaunchTime                | InstanceType | Name          |
+---------------------+---------+---------------------------+--------------+---------------+
| i-0bfc55c0abba070bd | Mark    | 2016-06-22 01:02:28+00:00 | t2.nano      | web-db        |
| i-0815cf4ac3811ef04 | Unknown | 2016-06-22 01:02:28+00:00 | t2.nano      | web-jobrunner |
| i-0cb0e38cdd63d9692 | Unknown | 2016-06-22 01:02:28+00:00 | t2.nano      | web-memcache  |
| i-00007089efb1c5551 | Jim     | 2016-06-22 01:02:28+00:00 | t2.nano      | web-server    |
+---------------------+---------+---------------------------+--------------+---------------+

instance-list's People

Contributors

mikevanwinkle avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.