diff --git a/Gemfile b/Gemfile index 4be8c17..20ff7d2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,4 @@ source 'https://rubygems.org' -gem 'aws-sdk' -gem 'trollop' -gem 'rspec' -gem 'aruba' +# Specify your gem's dependencies in aws-missing-tools.gemspec +gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 65e1dd1..130d0d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,10 @@ +PATH + remote: . + specs: + aws-missing-tools (0.0.1) + aws-sdk + trollop + GEM remote: https://rubygems.org/ specs: @@ -40,6 +47,5 @@ PLATFORMS DEPENDENCIES aruba - aws-sdk + aws-missing-tools! rspec - trollop diff --git a/aws-ha-release/README.md b/README.md similarity index 89% rename from aws-ha-release/README.md rename to README.md index 448677c..be461f9 100644 --- a/aws-ha-release/README.md +++ b/README.md @@ -1,27 +1,30 @@ -# Introduction: +# AWS HA Release + +## Introduction: aws-ha-release allows the high-availability / no downtime replacement of all EC2 Instances in an Auto Scaling Group that is behind an Elastic Load Balancer. # -# Potential Use: +## Potential Use: Some potential uses for aws-ha-release are listed below: 1. Delivery of new code - if your deployment scheme utilizes the termination of EC2 instances in order to release new code aws-ha-release provides an automated way to do this without incurring any downtime. 2. Return of all EC2 instances to "pristine" or "vanilla" state - all older EC2 instances can be replaced with newer EC2 instances. -# Directions For Use: -## Example of Use: +## Directions For Use: +### Example of Use: `aws-ha-release.sh -a my-scaling-group` the above example would terminate and replace each EC2 Instance in the Auto Scaling group "my-scaling-group" with a new EC2 Instance. -## Required Options: +### Required Options: aws-ha-release.sh requires the following option: `-a ` - the name of the Auto Scaling Group for which you wish to perform a high availability release. -## Optional Parameters: +### Optional Parameters: `-r ` - allows you specify the region in which your Auto Scaling Group is in. By default aws-ha-release assumes the "us-east-1" region. `-t ` - time, in seconds, in which an EC2 instance should be given to complete request processing prior to being terminated. Set this value high enough so that any requests sent through an ELB would have time to be completed by an EC2 instance. For example: if the ELB allows connections to stay open for 120 seconds then setting this value to 120 seconds allows an instance behind an ELB 120 seconds to complete all processing before being terminated. By default both an AWS ELB and aws-ha-release.sh utilize 60 seconds timeout period. `-i ` - allows you to specify the number of seconds an EC2 instance is provided to come into service. By default EC2 instances are given 300 seconds to come into service - if aws-ha-release.sh notices that an instance has not come into service in 300 seconds it will exit and return an exit status of 79. If an EC2 instance and application combination requires more than 300 seconds to come "InService" from the perspective of an ELB then this value should be set to a greater number. + # Additional Information: -- Author: Colin Johnson / colin@cloudavail.com -- Date: 2012-12-09 -- Version 0.1 +- Authors: Colin Johnson / colin@cloudavail.com, Anuj Biyani / abiyani@lytro.com +- Date: 2013-05-30 +- Version 0.0.1 - License Type: GNU GENERAL PUBLIC LICENSE, Version 3 diff --git a/aws-missing-tools.gemspec b/aws-missing-tools.gemspec new file mode 100644 index 0000000..5530458 --- /dev/null +++ b/aws-missing-tools.gemspec @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +require File.expand_path('../lib/aws-missing-tools/version', __FILE__) + +Gem::Specification.new do |gem| + gem.authors = ['Colin Johnson', 'Anuj Biyani'] + gem.email = %w(colin@cloudavail.com abiyani@lytro.com) + gem.description = %q{Extensions to Amazon's AWS CLI Tools.} + gem.summary = %q{A collection of useful tools to supplement the AWS CLI Tools. Many of these tools depend on official AWS tools to function.} + gem.homepage = 'https://github.com/colinbjohnson/aws-missing-tools/' + + gem.files = `git ls-files`.split("\n") + gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } + gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) + gem.name = 'aws-missing-tools' + gem.require_paths = %w(lib) + gem.version = AwsMissingTools::VERSION + + gem.add_dependency 'aws-sdk' + gem.add_dependency 'trollop' + + gem.add_development_dependency 'aruba' + gem.add_development_dependency 'rspec' +end diff --git a/aws-ha-release/aws-ha-release.rb b/bin/aws-ha-release.rb similarity index 94% rename from aws-ha-release/aws-ha-release.rb rename to bin/aws-ha-release.rb index 78d2d36..18f8e2c 100755 --- a/aws-ha-release/aws-ha-release.rb +++ b/bin/aws-ha-release.rb @@ -10,7 +10,7 @@ end opts = Trollop::options do opt :as_group_name, 'AutoScaling Group Name', type: :string, short: '-a' - opt :region, 'Region', type: :string, short: '-r' + opt :region, 'Region', default: 'us-east-1', type: :string, short: '-r' opt :elb_timeout, 'ELB Timeout', type: :int, default: 60, short: '-t' opt :inservice_time_allowed, 'InService Time Allowed', type: :int, default: 300, short: '-i' opt :aws_access_key, 'AWS Access Key', type: :string, short: '-o' diff --git a/aws-ha-release/aws-ha-release.sh b/bin/aws-ha-release.sh similarity index 100% rename from aws-ha-release/aws-ha-release.sh rename to bin/aws-ha-release.sh diff --git a/features/support/env.rb b/features/support/env.rb index 440d9cf..fb0a661 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -1,3 +1 @@ require 'aruba/cucumber' - -ENV['PATH'] = "#{Dir.pwd}/aws-ha-release#{File::PATH_SEPARATOR}#{ENV['PATH']}" diff --git a/lib/aws-missing-tools.rb b/lib/aws-missing-tools.rb new file mode 100644 index 0000000..87d7556 --- /dev/null +++ b/lib/aws-missing-tools.rb @@ -0,0 +1,8 @@ +require 'aws-missing-tools/version' + +module AwsMissingTools + require 'aws-sdk' + require 'trollop' + + require 'aws-missing-tools/aws-ha-release/aws-ha-release' +end diff --git a/lib/aws-missing-tools/aws-ha-release/aws-ha-release.rb b/lib/aws-missing-tools/aws-ha-release/aws-ha-release.rb new file mode 100755 index 0000000..fdccd04 --- /dev/null +++ b/lib/aws-missing-tools/aws-ha-release/aws-ha-release.rb @@ -0,0 +1,2 @@ +class AwsHaRelease +end diff --git a/lib/aws-missing-tools/version.rb b/lib/aws-missing-tools/version.rb new file mode 100644 index 0000000..3f6b46f --- /dev/null +++ b/lib/aws-missing-tools/version.rb @@ -0,0 +1,3 @@ +module AwsMissingTools + VERSION = '0.0.1' +end diff --git a/spec/aws-ha-release/aws-ha-release_spec.rb b/spec/aws-ha-release/aws-ha-release_spec.rb deleted file mode 100644 index 1d5de30..0000000 --- a/spec/aws-ha-release/aws-ha-release_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rspec' -require File.expand_path('aws-ha-release/aws-ha-release.rb') - -describe 'aws-ha-release' do -end diff --git a/spec/aws-missing-tools/aws-ha-release/aws-ha-release_spec.rb b/spec/aws-missing-tools/aws-ha-release/aws-ha-release_spec.rb new file mode 100644 index 0000000..57d3877 --- /dev/null +++ b/spec/aws-missing-tools/aws-ha-release/aws-ha-release_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe 'aws-ha-release' do + let(:opts) do + { + as_group_name: 'test_group', + aws_access_key: 'testaccesskey', + aws_secret_key: 'testsecretkey', + region: 'test-region' + } + end + + before do + AWS.stub(:config) + AWS::AutoScaling.stub(:new).and_return(AWS::FakeAutoScaling.new) + end + + describe '#initialize' do + it 'initializes the AWS connection' + it 'ensures the as group exists' + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..8f90512 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,8 @@ +require 'rspec' +require 'aws-missing-tools' + +Dir['spec/support/**/*.rb'].each { |f| require File.expand_path(f) } + +RSpec.configure do |config| + config.order = 'random' +end diff --git a/spec/support/fake_auto_scaling.rb b/spec/support/fake_auto_scaling.rb new file mode 100644 index 0000000..4905eec --- /dev/null +++ b/spec/support/fake_auto_scaling.rb @@ -0,0 +1,6 @@ +module AWS + class FakeAutoScaling + def initialize + end + end +end