ec2-instance-manager 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +112 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/ec2-instance-manager +0 -10
- data/config.yml.sample +17 -7
- data/ec2-instance-manager.gemspec +23 -27
- data/lib/ec2-instance-manager.rb +1 -0
- data/lib/ec2-instance-manager/ec2_instance_manager.rb +8 -7
- data/lib/ec2-instance-manager/launch.rb +66 -15
- data/lib/ec2-instance-manager/output.rb +1 -1
- data/lib/ec2-instance-manager/status.rb +5 -1
- data/test/ec2-instance-manager_test.rb +1 -1
- data/test/test_helper.rb +0 -1
- metadata +29 -24
- data/.gitignore +0 -5
- data/README.rdoc +0 -34
data/LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
ec2-instance-manager
|
2
|
+
====================
|
3
|
+
|
4
|
+
ec2-instance-manager is a command line utility written in ruby to manage Amazon EC2 instances and clusters (launchplan groups) for multiple AWS accounts (customer config keys).
|
5
|
+
|
6
|
+
You can launch and terminate EC2 instances, create whole launchplans of instances divided into groups, start all launchplan groups or start a specific launchplan group, assign public IP's and attach volumes.
|
7
|
+
|
8
|
+
|
9
|
+
Installation:
|
10
|
+
-------------
|
11
|
+
|
12
|
+
[sudo] gem install amazon-ec2 ec2-instance-manager
|
13
|
+
|
14
|
+
|
15
|
+
Configuration:
|
16
|
+
--------------
|
17
|
+
|
18
|
+
You can either run ec2-instance-manager from a local "config.yml" in your current work directory or use a global ".ec2_instance_manager_config.yml" in your home directory. If a local configuration file in the current work directory is found, it has precendence over the global configuration file.
|
19
|
+
|
20
|
+
There are basically two types of launchplan instance definitions:
|
21
|
+
|
22
|
+
1. Simple
|
23
|
+
2. Detailed
|
24
|
+
|
25
|
+
With the simple type you can quickly launch a number of instances by their AMI ID. This type uses the default settings for availability_zone, instance_type and architecture.
|
26
|
+
|
27
|
+
If you need fine-grained control over each instance, you should go for the detailed launchplan instance definition. You can name each instance in a group. Make sure the instance nicknames are unique.
|
28
|
+
|
29
|
+
Each definition consists of the following required values:
|
30
|
+
|
31
|
+
* AMI ID
|
32
|
+
* Architecture (x86_64 or i386)
|
33
|
+
* EC2 Instance Type
|
34
|
+
|
35
|
+
You can also specify the following optional values:
|
36
|
+
|
37
|
+
* Elastic IP to assign
|
38
|
+
* Volumes to attach at a given mountpoint (Comma separated)
|
39
|
+
|
40
|
+
The instances are created sequentially in order of their definition.
|
41
|
+
|
42
|
+
Configuration example:
|
43
|
+
|
44
|
+
default: # Default customer config key
|
45
|
+
amazon_access_key_id: YOUR_ACCESS_KEY
|
46
|
+
amazon_secret_access_key: YOUR_SECRET
|
47
|
+
amazon_account_number: YOUR_CUSTOMER_NUMBER
|
48
|
+
ec2_server_region: "eu-west-1.ec2.amazonaws.com"
|
49
|
+
key: YOUR_SSH_KEY
|
50
|
+
availability_zone: eu-west-1a
|
51
|
+
instance_type: t1.micro
|
52
|
+
architecture: x86_64 #i386
|
53
|
+
launch_plan:
|
54
|
+
webservers:
|
55
|
+
"ami_id_xxx1": 2
|
56
|
+
dbservers:
|
57
|
+
"ami_id_xxx2": 1
|
58
|
+
detailed:
|
59
|
+
"appserver1": "ami_id_xxx3;x86_64;t1.micro;"
|
60
|
+
"appserver2": "ami_id_xxx3;x86_64;t1.micro;192.168.1.1;vol-xxx1@/dev/sdf,vol-xxx2@/dev/sdg"
|
61
|
+
"appserver3": "ami_id_xxx3;x86_64;t1.micro;;vol-xxx3@/dev/sdf,vol-xxx4@/dev/sdg"
|
62
|
+
|
63
|
+
|
64
|
+
Please have a look at the "config.yml.sample" for further configuration examples.
|
65
|
+
|
66
|
+
|
67
|
+
Usage:
|
68
|
+
------
|
69
|
+
|
70
|
+
Run ec2-instance-manager --help for options and commands.
|
71
|
+
|
72
|
+
ec2-instance-manager 0.4.0 [options]
|
73
|
+
-s, --status Status only
|
74
|
+
-t, --terminate-all Terminates all instances running under a customer config key
|
75
|
+
-l, --start-launch-plan Starts a launch plan under a customer config key
|
76
|
+
-g, --group LAUNCH_GROUP_NAME Starts a launch plan group under a customer config key
|
77
|
+
-c, --config CONFIG_KEY Sets the customer config key
|
78
|
+
-h, --help Display this screen
|
79
|
+
|
80
|
+
|
81
|
+
Examples:
|
82
|
+
---------
|
83
|
+
|
84
|
+
Checking the status of your instances/cluster:
|
85
|
+
|
86
|
+
ec2-instance-manager -c YOUR_CONFIG_KEY -s
|
87
|
+
|
88
|
+
Terminating all instances:
|
89
|
+
|
90
|
+
ec2-instance-manager -c YOUR_CONFIG_KEY -t
|
91
|
+
|
92
|
+
Terminating all instances of a launch group:
|
93
|
+
|
94
|
+
ec2-instance-manager -c YOUR_CONFIG_KEY -g LAUNCH_GROUP_NAME -t
|
95
|
+
|
96
|
+
Launching all groups of your launchplan:
|
97
|
+
|
98
|
+
ec2-instance-manager -c YOUR_CONFIG_KEY -l
|
99
|
+
|
100
|
+
Launching a specific group of your launchplan:
|
101
|
+
|
102
|
+
ec2-instance-manager -c YOUR_CONFIG_KEY -g LAUNCH_GROUP_NAME -l
|
103
|
+
|
104
|
+
Launching an individual instance without a definition (launch console):
|
105
|
+
|
106
|
+
ec2-instance-manager -c YOUR_CONFIG_KEY
|
107
|
+
|
108
|
+
|
109
|
+
Copyright
|
110
|
+
---------
|
111
|
+
|
112
|
+
Copyright (c) 2009-2011 Oliver Kiessler. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/okiess/ec2-instance-manager"
|
12
12
|
gem.authors = ["Oliver Kiessler"]
|
13
13
|
gem.add_dependency "amazon-ec2"
|
14
|
-
gem.add_development_dependency "
|
14
|
+
# gem.add_development_dependency "shoulda"
|
15
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
16
|
end
|
17
17
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/bin/ec2-instance-manager
CHANGED
@@ -2,16 +2,6 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/../lib/ec2-instance-manager'
|
4
4
|
|
5
|
-
if ENV['AMAZON_ACCESS_KEY_ID'].nil? or ENV['AMAZON_SECRET_ACCESS_KEY'].nil?
|
6
|
-
if ENV['AMAZON_ACCESS_KEY_ID'].nil?
|
7
|
-
puts "Please set your AMAZON_ACCESS_KEY_ID environment variable (for your default account)."
|
8
|
-
end
|
9
|
-
if ENV['AMAZON_SECRET_ACCESS_KEY'].nil?
|
10
|
-
puts "Please set your AMAZON_SECRET_ACCESS_KEY environment variable (for your default account)."
|
11
|
-
end
|
12
|
-
exit
|
13
|
-
end
|
14
|
-
|
15
5
|
# Create and run the application
|
16
6
|
app = Ec2InstanceManager.new(ARGV, STDIN)
|
17
7
|
app.run
|
data/config.yml.sample
CHANGED
@@ -1,31 +1,41 @@
|
|
1
|
-
default:
|
1
|
+
default: # Default customer config key
|
2
2
|
amazon_access_key_id:
|
3
3
|
amazon_secret_access_key:
|
4
4
|
amazon_account_number:
|
5
|
+
ec2_server_region: "eu-west-1.ec2.amazonaws.com"
|
5
6
|
key:
|
6
7
|
availability_zone: eu-west-1a
|
7
|
-
instance_type:
|
8
|
+
instance_type: t1.micro
|
9
|
+
architecture: x86_64 #i386
|
8
10
|
launch_plan:
|
9
|
-
|
10
|
-
"ami_id_xxx1":
|
11
|
-
|
12
|
-
"ami_id_xxx2": 1
|
11
|
+
webservers:
|
12
|
+
"ami_id_xxx1": 2
|
13
|
+
dbservers:
|
14
|
+
"ami_id_xxx2": 1
|
15
|
+
detailed:
|
16
|
+
"appserver1": "ami_id_xxx3;x86_64;t1.micro;"
|
17
|
+
"appserver2": "ami_id_xxx3;x86_64;t1.micro;192.168.1.1;vol-xxx1@/dev/sdf,vol-xxx2@/dev/sdg"
|
18
|
+
"appserver3": "ami_id_xxx3;x86_64;t1.micro;;vol-xxx3@/dev/sdf,vol-xxx4@/dev/sdg"
|
13
19
|
|
14
|
-
customer1:
|
20
|
+
customer1: # another AWS account
|
15
21
|
amazon_access_key_id:
|
16
22
|
amazon_secret_access_key:
|
17
23
|
amazon_account_number:
|
24
|
+
ec2_server_region: "eu-west-1.ec2.amazonaws.com"
|
18
25
|
key:
|
19
26
|
availability_zone: eu-west-1a
|
20
27
|
instance_type: m1.small
|
28
|
+
architecture: i386
|
21
29
|
|
22
30
|
customer2:
|
23
31
|
amazon_access_key_id:
|
24
32
|
amazon_secret_access_key:
|
25
33
|
amazon_account_number:
|
34
|
+
ec2_server_region: "eu-west-1.ec2.amazonaws.com"
|
26
35
|
key:
|
27
36
|
availability_zone: eu-west-1a
|
28
37
|
instance_type: m1.small
|
38
|
+
architecture: i386
|
29
39
|
launch_plan:
|
30
40
|
group1:
|
31
41
|
ami_id_xxx1: 1
|
@@ -1,64 +1,60 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ec2-instance-manager}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oliver Kiessler"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-02-05}
|
13
13
|
s.default_executable = %q{ec2-instance-manager}
|
14
14
|
s.description = %q{Launches EC2 instances for multiple AWS accounts}
|
15
15
|
s.email = %q{kiessler@inceedo.com}
|
16
16
|
s.executables = ["ec2-instance-manager"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
|
-
|
19
|
+
"README.md"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
"test/test_helper.rb"
|
23
|
+
"LICENSE",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/ec2-instance-manager",
|
28
|
+
"config.yml.sample",
|
29
|
+
"ec2-instance-manager.gemspec",
|
30
|
+
"lib/ec2-instance-manager.rb",
|
31
|
+
"lib/ec2-instance-manager/ec2_instance_manager.rb",
|
32
|
+
"lib/ec2-instance-manager/launch.rb",
|
33
|
+
"lib/ec2-instance-manager/output.rb",
|
34
|
+
"lib/ec2-instance-manager/status.rb",
|
35
|
+
"test/ec2-instance-manager_test.rb",
|
36
|
+
"test/test_helper.rb"
|
38
37
|
]
|
39
38
|
s.homepage = %q{http://github.com/okiess/ec2-instance-manager}
|
40
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
41
39
|
s.require_paths = ["lib"]
|
42
|
-
s.rubygems_version = %q{1.3.
|
40
|
+
s.rubygems_version = %q{1.3.7}
|
43
41
|
s.summary = %q{Simple EC2 Instance Manager}
|
44
42
|
s.test_files = [
|
45
43
|
"test/ec2-instance-manager_test.rb",
|
46
|
-
|
44
|
+
"test/test_helper.rb"
|
47
45
|
]
|
48
46
|
|
49
47
|
if s.respond_to? :specification_version then
|
50
48
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
51
49
|
s.specification_version = 3
|
52
50
|
|
53
|
-
if Gem::Version.new(Gem::
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
52
|
s.add_runtime_dependency(%q<amazon-ec2>, [">= 0"])
|
55
|
-
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
56
53
|
else
|
57
54
|
s.add_dependency(%q<amazon-ec2>, [">= 0"])
|
58
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
59
55
|
end
|
60
56
|
else
|
61
57
|
s.add_dependency(%q<amazon-ec2>, [">= 0"])
|
62
|
-
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
63
58
|
end
|
64
59
|
end
|
60
|
+
|
data/lib/ec2-instance-manager.rb
CHANGED
@@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/output'
|
|
4
4
|
|
5
5
|
class Ec2InstanceManager
|
6
6
|
include Status, Launch, Output
|
7
|
-
VERSION = '0.
|
7
|
+
VERSION = '0.4.0'
|
8
8
|
|
9
9
|
attr_reader :config, :customer_key, :options
|
10
10
|
|
@@ -22,22 +22,22 @@ class Ec2InstanceManager
|
|
22
22
|
end
|
23
23
|
|
24
24
|
options[:terminate] = false
|
25
|
-
opts.on( '-t', '--terminate-all', 'Terminates all instances running under a config key' ) do
|
25
|
+
opts.on( '-t', '--terminate-all', 'Terminates all instances running under a customer config key' ) do
|
26
26
|
options[:terminate] = true
|
27
27
|
end
|
28
28
|
|
29
29
|
options[:start_launch_plan] = false
|
30
|
-
opts.on( '-l', '--start-launch-plan', 'Starts a launch plan under a config key' ) do
|
30
|
+
opts.on( '-l', '--start-launch-plan', 'Starts a launch plan under a customer config key' ) do
|
31
31
|
options[:start_launch_plan] = true
|
32
32
|
end
|
33
33
|
|
34
34
|
options[:group] = nil
|
35
|
-
opts.on( '-g', '--group LAUNCH_GROUP_NAME', 'Starts a launch plan group under a config key' ) do |group|
|
35
|
+
opts.on( '-g', '--group LAUNCH_GROUP_NAME', 'Starts a launch plan group under a customer config key' ) do |group|
|
36
36
|
options[:group] = group
|
37
37
|
end
|
38
38
|
|
39
39
|
options[:config] = nil
|
40
|
-
opts.on( '-c', '--config CONFIG_KEY', 'Sets the config key' ) do |key|
|
40
|
+
opts.on( '-c', '--config CONFIG_KEY', 'Sets the customer config key' ) do |key|
|
41
41
|
options[:config] = key
|
42
42
|
end
|
43
43
|
|
@@ -67,8 +67,9 @@ class Ec2InstanceManager
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def ec2
|
70
|
-
@ec2
|
71
|
-
:secret_access_key => config[@customer_key]['amazon_secret_access_key']
|
70
|
+
@ec2 = AWS::EC2::Base.new(:access_key_id => config[@customer_key]['amazon_access_key_id'],
|
71
|
+
:secret_access_key => config[@customer_key]['amazon_secret_access_key'],
|
72
|
+
:server => config[@customer_key]['ec2_server_region'])
|
72
73
|
end
|
73
74
|
|
74
75
|
def run
|
@@ -61,21 +61,26 @@ module Launch
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def start_launch_plan
|
64
|
-
ami_ids_to_launch = []
|
64
|
+
ami_ids_to_launch = []; detailed_ami_ids_to_launch = []
|
65
65
|
puts
|
66
66
|
puts "Your Launch Plan:"
|
67
67
|
if config[@customer_key]["launch_plan"] and config[@customer_key]["launch_plan"].any?
|
68
|
-
|
68
|
+
|
69
69
|
launch_plan_groups = config[@customer_key]["launch_plan"].keys.sort
|
70
|
-
|
70
|
+
|
71
71
|
if self.options[:group]
|
72
72
|
puts
|
73
73
|
puts "Existing groups: #{launch_plan_groups.join(", ")}"
|
74
74
|
if launch_plan_groups.include?(self.options[:group])
|
75
75
|
puts "Targeted Group: #{self.options[:group]}"
|
76
76
|
config[@customer_key]["launch_plan"][self.options[:group]].each do |ami_id|
|
77
|
-
|
78
|
-
|
77
|
+
if (ami_id[1].is_a?(Fixnum))
|
78
|
+
puts "#{ami_id[0]} => #{ami_id[1]} Instances to launch"
|
79
|
+
ami_ids_to_launch << [ami_id[0], ami_id[1]]
|
80
|
+
else
|
81
|
+
puts "#{ami_id[0]} => Detailed launch: #{ami_id[1]}"
|
82
|
+
detailed_ami_ids_to_launch << [ami_id[0], ami_id[1]]
|
83
|
+
end
|
79
84
|
end
|
80
85
|
else
|
81
86
|
puts white("Targeted Launch plan group '#{self.options[:group]}' not found.")
|
@@ -86,8 +91,13 @@ module Launch
|
|
86
91
|
puts "Group: #{launch_plan_group}"
|
87
92
|
if config[@customer_key]["launch_plan"][launch_plan_group] and config[@customer_key]["launch_plan"][launch_plan_group].any?
|
88
93
|
config[@customer_key]["launch_plan"][launch_plan_group].keys.each do |ami_id|
|
89
|
-
|
90
|
-
|
94
|
+
if (config[@customer_key]["launch_plan"][launch_plan_group][ami_id].is_a?(Fixnum))
|
95
|
+
puts "#{ami_id} => #{config[@customer_key]["launch_plan"][launch_plan_group][ami_id]} Instances to launch"
|
96
|
+
ami_ids_to_launch << [ami_id, config[@customer_key]["launch_plan"][launch_plan_group][ami_id]]
|
97
|
+
else
|
98
|
+
puts "#{ami_id} => Detailed launch: #{config[@customer_key]["launch_plan"][launch_plan_group][ami_id]}"
|
99
|
+
detailed_ami_ids_to_launch << [ami_id, config[@customer_key]["launch_plan"][launch_plan_group][ami_id]]
|
100
|
+
end
|
91
101
|
end
|
92
102
|
else
|
93
103
|
puts white("No Ami Id's to launch defined.")
|
@@ -97,7 +107,7 @@ module Launch
|
|
97
107
|
|
98
108
|
puts
|
99
109
|
puts red("Warning: Now launching your plan...")
|
100
|
-
puts red("Please cancel within the next 5 seconds if this isn't
|
110
|
+
puts red("Please press CTRL-C to cancel within the next 5 seconds if this isn't what you want...")
|
101
111
|
puts
|
102
112
|
sleep 5
|
103
113
|
|
@@ -107,20 +117,61 @@ module Launch
|
|
107
117
|
result = launch_ami(group_ami_id_pair[0])
|
108
118
|
}
|
109
119
|
end
|
120
|
+
puts if ami_ids_to_launch.any?
|
121
|
+
|
122
|
+
detailed_ami_ids_to_launch.each do |group_ami_id_pair|
|
123
|
+
your_instance_name = group_ami_id_pair[0]
|
124
|
+
instance_assignments = group_ami_id_pair[1].split(";")
|
125
|
+
ami_id = instance_assignments[0]
|
126
|
+
raise "Incomplete detailed launchplan definition." if instance_assignments.size < 3
|
127
|
+
|
128
|
+
puts "Launching '#{your_instance_name}'..."
|
129
|
+
architecture = instance_assignments[1]; instance_type = instance_assignments[2]
|
130
|
+
result = launch_ami(ami_id, {:instance_type => instance_type, :architecture => architecture})
|
131
|
+
|
132
|
+
if result and result["instancesSet"]["item"] and (instance_id = result["instancesSet"]["item"][0]["instanceId"])
|
133
|
+
instance_state = ''
|
134
|
+
while(instance_state != 'running') do
|
135
|
+
instance_state, dns_name = get_instance_state(instance_id)
|
136
|
+
puts "Running state of instance #{instance_id}: #{output_running_state(instance_state)}"
|
137
|
+
sleep 5
|
138
|
+
end
|
139
|
+
|
140
|
+
if instance_assignments[3] and not instance_assignments[3].empty?
|
141
|
+
puts "Associating IP #{instance_assignments[3]}..."
|
142
|
+
result = ec2.associate_address(:instance_id => instance_id, :public_ip => instance_assignments[3])
|
143
|
+
end
|
144
|
+
|
145
|
+
if instance_assignments[4] and not instance_assignments[4].empty?
|
146
|
+
volumes = instance_assignments[4].split(",")
|
147
|
+
volumes.each do |volume_pair|
|
148
|
+
volume = volume_pair.split("@")
|
149
|
+
puts "Attaching volume #{volume[0]} at mount point #{volume[1]}..."
|
150
|
+
result = ec2.attach_volume(:volume_id => volume[0], :instance_id => instance_id, :device => volume[1])
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
puts
|
155
|
+
end
|
110
156
|
|
111
|
-
puts white("
|
157
|
+
puts white("Launchplan executed!")
|
112
158
|
else
|
113
159
|
puts white("No launch plan groups defined.")
|
114
160
|
end
|
115
161
|
end
|
116
162
|
|
117
|
-
def launch_ami(ami_id)
|
118
|
-
|
119
|
-
|
120
|
-
:instance_type => config[@customer_key]['instance_type'],
|
163
|
+
def launch_ami(ami_id, options = {})
|
164
|
+
default_options = {
|
165
|
+
:instance_type => config[@customer_key]['instance_type'],
|
121
166
|
:key_name => config[@customer_key]['key'],
|
122
|
-
:availability_zone => config[@customer_key]['availability_zone']
|
123
|
-
|
167
|
+
:availability_zone => config[@customer_key]['availability_zone'],
|
168
|
+
:architecture => config[@customer_key]['architecture'],
|
169
|
+
:image_id => ami_id
|
170
|
+
}
|
171
|
+
|
172
|
+
run_options = default_options.merge(options)
|
173
|
+
puts "Launch Options: #{run_options.inspect}"
|
174
|
+
ec2.run_instances(run_options)
|
124
175
|
end
|
125
176
|
|
126
177
|
private
|
@@ -13,7 +13,7 @@ module Output
|
|
13
13
|
|
14
14
|
def cancel_message(instances)
|
15
15
|
puts red("Warning: Terminating all instances: #{instances.join(", ")}")
|
16
|
-
puts red("Please cancel within the next 5 seconds if this isn't
|
16
|
+
puts red("Please press CTRL-C to cancel within the next 5 seconds if this isn't what you want...")
|
17
17
|
end
|
18
18
|
|
19
19
|
def green(str)
|
@@ -49,7 +49,11 @@ module Status
|
|
49
49
|
if vol["attachmentSet"]
|
50
50
|
instance_id = vol["attachmentSet"]["item"].first["instanceId"]
|
51
51
|
end
|
52
|
-
|
52
|
+
if vol["status"] == 'deleting'
|
53
|
+
puts "#{white(vol["volumeId"])} (Size: #{vol["size"]} / Zone: #{vol["availabilityZone"]}) - #{vol["status"]}"
|
54
|
+
else
|
55
|
+
puts "#{white(vol["volumeId"])} (Size: #{vol["size"]} / Zone: #{vol["availabilityZone"]}) - #{vol["status"]} => #{instance_id.nil? ? 'unassigned' : instance_id}"
|
56
|
+
end
|
53
57
|
end
|
54
58
|
else
|
55
59
|
puts white("No volumes.")
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ec2-instance-manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Oliver Kiessler
|
@@ -9,29 +15,23 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2011-02-05 00:00:00 +01:00
|
13
19
|
default_executable: ec2-instance-manager
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: amazon-ec2
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: thoughtbot-shoulda
|
27
|
-
type: :development
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
30
26
|
requirements:
|
31
27
|
- - ">="
|
32
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
33
32
|
version: "0"
|
34
|
-
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
35
|
description: Launches EC2 instances for multiple AWS accounts
|
36
36
|
email: kiessler@inceedo.com
|
37
37
|
executables:
|
@@ -40,12 +40,11 @@ extensions: []
|
|
40
40
|
|
41
41
|
extra_rdoc_files:
|
42
42
|
- LICENSE
|
43
|
-
- README.
|
43
|
+
- README.md
|
44
44
|
files:
|
45
45
|
- .document
|
46
|
-
- .gitignore
|
47
46
|
- LICENSE
|
48
|
-
- README.
|
47
|
+
- README.md
|
49
48
|
- Rakefile
|
50
49
|
- VERSION
|
51
50
|
- bin/ec2-instance-manager
|
@@ -63,26 +62,32 @@ homepage: http://github.com/okiess/ec2-instance-manager
|
|
63
62
|
licenses: []
|
64
63
|
|
65
64
|
post_install_message:
|
66
|
-
rdoc_options:
|
67
|
-
|
65
|
+
rdoc_options: []
|
66
|
+
|
68
67
|
require_paths:
|
69
68
|
- lib
|
70
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
74
77
|
version: "0"
|
75
|
-
version:
|
76
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
77
80
|
requirements:
|
78
81
|
- - ">="
|
79
82
|
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
80
86
|
version: "0"
|
81
|
-
version:
|
82
87
|
requirements: []
|
83
88
|
|
84
89
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.3.
|
90
|
+
rubygems_version: 1.3.7
|
86
91
|
signing_key:
|
87
92
|
specification_version: 3
|
88
93
|
summary: Simple EC2 Instance Manager
|
data/README.rdoc
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
= ec2-instance-manager
|
2
|
-
|
3
|
-
Simple EC2 Instance Manager that is able to work with multiple AWS accounts (in config.yml). See config.yml.sample.
|
4
|
-
|
5
|
-
Create a "config.yml" in the current directory and run "ec2_instance_manager". You can launch & terminate instances, create whole launch plans, start all launch plan groups or start an individual launch plan group, assign public IP's and attach volumes.
|
6
|
-
|
7
|
-
Run ec2-instance-manager --help for options and commands.
|
8
|
-
|
9
|
-
This gem should be considered ALPHA! More features to come...
|
10
|
-
|
11
|
-
== Installation
|
12
|
-
|
13
|
-
sudo gem install amazon-ec2
|
14
|
-
|
15
|
-
sudo gem install ec2-instance-manager (Gemcutter)
|
16
|
-
|
17
|
-
or
|
18
|
-
|
19
|
-
sudo gem install okiess-ec2-instance-manager (Github)
|
20
|
-
|
21
|
-
== Note on Patches/Pull Requests
|
22
|
-
|
23
|
-
* Fork the project.
|
24
|
-
* Make your feature addition or bug fix.
|
25
|
-
* Add tests for it. This is important so I don't break it in a
|
26
|
-
future version unintentionally.
|
27
|
-
* Commit, do not mess with rakefile, version, or history.
|
28
|
-
(if you want to have your own version, that is fine but
|
29
|
-
bump version in a commit by itself I can ignore when I pull)
|
30
|
-
* Send me a pull request. Bonus points for topic branches.
|
31
|
-
|
32
|
-
== Copyright
|
33
|
-
|
34
|
-
Copyright (c) 2009 Oliver Kiessler. See LICENSE for details.
|