Giter Site home page Giter Site logo

ec2-retirement-bulk-fix's Introduction

About

This script allows you to:

  • List all AWS EC2 instances that are scheduled for retirement in a given region
  • Do a bulk stop and start of these instances (so that they are migrated to new hardware)

You could use this to automate handling of instance retirements. Or to make life easier if you manage many EC2 instances and thus get a ton of retirement notices at once.

Install

git clone https://github.com/snobear/ec2-retirement-bulk-fix.git
cd ec2-retirement-bulk-fix
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

Usage

Set your AWS access key and secret

export AWS_ACCESS_KEY_ID="KEY-GOES-HERE"
export AWS_SECRET_ACCESS_KEY="secret"

List instances scheduled for retirement

./retired.py --region us-west-2 --list

Stop and start instances scheduled for retirement

This will stop and start all instances one at a time:

./retired.py --region us-west-2 --stopstart

Excluding instances

You can optionally ignore instances by name. Currently, this is hardcoded in, so anything you want to exclude by name can be added to the exclude_names list in this function in the script:

def get_instances(region, exclude_names=['master','search']):

A PR would be appreciated to parameterize this :).

Help

./retired.py --help

About EC2 Instance Retirements

Occasionally, you'll receive a notice from AWS that your EC2 instance is scheduled for retirement. Per AWS docs,

An instance is scheduled to be retired when AWS detects irreparable failure of the underlying hardware hosting the instance. When an instance reaches its scheduled retirement date, it is stopped or terminated by AWS. If your instance root device is an Amazon EBS volume, the instance is stopped, and you can start it again at any time. Starting the stopped instance migrates it to new hardware. If your instance root device is an instance store volume, the instance is terminated, and cannot be used again.

Contributing

Issues and pull requests are quite welcome.

ec2-retirement-bulk-fix's People

Contributors

aktur avatar snobear avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

aktur

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.