Code Monkey home page Code Monkey logo

ec2's Introduction

ec2

ec2 is a simple shell script that helps you to log into your EC2 instances using the tag "Name".

Screenshot

Setting up

Donwload ec2 script

Download the source code from github:

git clone https://github.com/sirio7g/ec2.git

Install boto library

ec2 script is built on top of boto library then, first of all, install them using pip:

sudo pip install boto

#
# If 'pip' is not installed on your machine, try with:
# sudo easy_install pip
#

In most case if is enough but if you are running Mountain Lion you might need to export the variable as follow:

export PYTHONPATH=/usr/bin/python2.7
export PYTHONPATH=${PYTHONPATH}:$HOME/code/python/boto

change the python version according to your own.

Edit the configuration file

Since ec2 script wants to be a very quick shortcut to jump into your instances, it uses a property file in order to load default settings i.e. username, default pem file, default region, etc. Therefore, you must edit configuration file:

vi conf/.ec2-default.props

Then you have to add the ec2 directory to your PATH env variable:

export EC2_SCRIPT_HOME=/path_of_ec2/
export PATH=$PATH:$EC2_SCRIPT_HOME/bin

persistent it by adding the above line to your ~/.bash_profile or ~/.profile.

Usage

ec2 [-i] [-u user] [-x] [-c "command"] [eu|us|us-west-1|region]

Arguments:
	-u user
	-i print instances's details
	-k PEM file
	-x Export display
	-c "command (sent by ssh)"

ec2 allows to run command (by ssh) on a server or even onto a list of servers using the โ€œ-cโ€ argument, look at the example below:

Screenshot

Example

List all your instance in your default US region:

sirio7g@laptop$ ec2 us
hadoop-master (ec2-51-227-4-45.eu-west-1.compute.amazonaws.com)
hadoop-node1 (ec2-41-53-145-104.eu-west-1.compute.amazonaws.com)
hadoop-node2 (ec2-44-138-149-215.eu-west-1.compute.amazonaws.com)
Pick your option(s) (use space to specify more instances, i.e: 1 2 3 4):

Join as "ubuntu" user:

sirio7g@laptop$ ec2 -u ubuntu
hadoop-master (ec2-51-227-4-45.eu-west-1.compute.amazonaws.com)
hadoop-node1 (ec2-41-53-145-104.eu-west-1.compute.amazonaws.com)
hadoop-node2 (ec2-44-138-149-215.eu-west-1.compute.amazonaws.com)
Pick your option(s) (use space to specify more instances, i.e: 1 2 3 4): 1
Connecting to hadoop-master 
ssh -i /home/sirio7g/my.pem [email protected]

ubuntu@hadoop-master:~$ 

Join as "ubuntu" user, print "date" on a list of instances and exit:

sirio7g@laptop$ ec2 -u ubuntu -c "date; exit"
hadoop-master (ec2-51-227-4-45.eu-west-1.compute.amazonaws.com)
hadoop-node1 (ec2-41-53-145-104.eu-west-1.compute.amazonaws.com)
hadoop-node2 (ec2-44-138-149-215.eu-west-1.compute.amazonaws.com)
Pick your option(s) (use space to specify more instances, i.e: 1 2 3 4): 1 2
Connecting to hadoop-master       
ssh -i /home/sirio7g/my.pem [email protected]
Fri Feb 15 10:42:50 CET 2013
Connecting to hadoop-node1
ssh -i /home/sirio7g/my.pem [email protected]
Fri Feb 15 10:42:50 CET 2013
sirio7g@laptop$

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.