Code Monkey home page Code Monkey logo

ec2-spot-instance-launcher's Introduction

ec2-spot-instance-launcher

This is a Python script that brings up a spot EC2 instance (of a specified type, region and maximimum bid), and tags it. It also allows to list and stop active instances.

Prerequisites

  • Python 2.6 (ish)
  • Boto library

Configuration

A template configuration file is provided in ec2-spot-instance-launcher.cfg.defaults (rename it to ec2-spot-instance-launcher.cfg).

These are some important parameters:

  • ami Unfortunately you will need to manually find the AMI to use in your region
  • key_pair You will need a named keypair on EC2 for instance creation
  • security_group Ditto
  • tag A tag that will be used by the script to identify the instance's purpose
  • user_data User data be passed by the script to instance
  • user_data_file User data file would be used if user_data is not set. Script would read the file content, and pass the same to instance as user-data

Some thoughts

IAM user needs to have access to a number of EC2 API calls, I believe they are:

  • DescribeInstances
  • DescribeSpotPriceHistoryRequest
  • DescribeSpotInstanceRequests
  • RequestSpotInstances

The script is written in a fairly platform agnostic way but it's only been tested on Mac OSX.

Expected behavior

First connect should go something like:

python main.py
Spot price is 0.02... below maximum bid, continuing
Spot request created, status: open
Waiting for instance to be provisioned (usually takes 1m to be reviewed, another 2m to be fulfilled) ...  . . . Instance is active.
Tagging instance... Done.
Waiting for server to come up ... . . . . Server is up!

Subsequent connects:

python main.py
Instance exists already, we will not be provisioning another one
Waiting for server to come up ... Server is up!

Terminating (and detagging) the instance:

python main.py stop
Terminating i-0a1b1930 ... done.

Credits

Most code comes from spot-ec2-proxifier project

ec2-spot-instance-launcher's People

Contributors

abdul avatar alexzorin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.