awscli 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +8 -8
  2. data/README.rdoc +5 -0
  3. data/Rakefile +44 -0
  4. data/bin/awscli +32 -0
  5. data/features/awscli.feature +8 -0
  6. data/features/step_definitions/awscli_steps.rb +6 -0
  7. data/features/support/env.rb +15 -0
  8. data/lib/awscli.rb +51 -0
  9. data/lib/awscli/as.rb +289 -0
  10. data/lib/awscli/cli.rb +21 -0
  11. data/lib/awscli/cli/as.rb +12 -0
  12. data/lib/awscli/cli/as/activities.rb +28 -0
  13. data/lib/awscli/cli/as/configurations.rb +50 -0
  14. data/lib/awscli/cli/as/groups.rb +97 -0
  15. data/lib/awscli/cli/as/instances.rb +34 -0
  16. data/lib/awscli/cli/as/policies.rb +45 -0
  17. data/lib/awscli/cli/ec2.rb +23 -0
  18. data/lib/awscli/cli/ec2/ami.rb +46 -0
  19. data/lib/awscli/cli/ec2/ebs.rb +85 -0
  20. data/lib/awscli/cli/ec2/eip.rb +56 -0
  21. data/lib/awscli/cli/ec2/instances.rb +216 -0
  22. data/lib/awscli/cli/ec2/keypairs.rb +60 -0
  23. data/lib/awscli/cli/ec2/monitoring.rb +35 -0
  24. data/lib/awscli/cli/ec2/placement.rb +42 -0
  25. data/lib/awscli/cli/ec2/reservedinstmng.rb +45 -0
  26. data/lib/awscli/cli/ec2/secgroups.rb +66 -0
  27. data/lib/awscli/cli/ec2/spot.rb +81 -0
  28. data/lib/awscli/cli/ec2/subnet.rb +43 -0
  29. data/lib/awscli/cli/ec2/tags.rb +45 -0
  30. data/lib/awscli/cli/ec2/vmmng.rb +17 -0
  31. data/lib/awscli/cli/ec2/vpc.rb +42 -0
  32. data/lib/awscli/cli/ec2/vpc/connections.rb +0 -0
  33. data/lib/awscli/cli/ec2/vpc/cust_gateways.rb +0 -0
  34. data/lib/awscli/cli/ec2/vpc/dhcp.rb +51 -0
  35. data/lib/awscli/cli/ec2/vpc/internet_gateways.rb +58 -0
  36. data/lib/awscli/cli/ec2/vpc/net_interfaces.rb +75 -0
  37. data/lib/awscli/cli/ec2/vpc/network_acls.rb +29 -0
  38. data/lib/awscli/cli/ec2/vpc/priv_gatewats.rb +0 -0
  39. data/lib/awscli/cli/ec2/vpc/route_tables.rb +0 -0
  40. data/lib/awscli/cli/s3.rb +12 -0
  41. data/lib/awscli/cli/s3/directories.rb +82 -0
  42. data/lib/awscli/cli/s3/files.rb +77 -0
  43. data/lib/awscli/connection.rb +55 -0
  44. data/lib/awscli/ec2.rb +821 -0
  45. data/lib/awscli/errors.rb +64 -0
  46. data/lib/awscli/helper.rb +8 -0
  47. data/lib/awscli/s3.rb +108 -0
  48. data/lib/awscli/version.rb +3 -0
  49. data/test/default_test.rb +14 -0
  50. data/test/test_helper.rb +9 -0
  51. metadata +59 -4
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzJlN2M3MjNkZTMxMjM5ZmFhYTUwNTBjNTczMmQ5ZjI4NGY2MjllYw==
4
+ NjBjNDc0NmJmYzY0NzA5ZWE0M2Q0ODllNmIwMWI5MDY5ZjE3MjM1ZQ==
5
5
  data.tar.gz: !binary |-
6
- ZmVhNDhiZjMxNjM0YTIzM2ZhNzFlMDY3NTg0MTEwMzE3ZGUxZDI5NA==
6
+ NjA1MDA0NjJiYzJhNGM5NmFlMTdlN2ViYTBkYmQ1N2U5MzU0MWRhZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OGFlZTc5NzczMmFiNzU5Mzc2Y2E3M2U5OGQxODE5MWI4MjJkMjJhZDk2ZWNj
10
- YjJiNWVjNmUzY2RiOTllNzZmOTQzNDEwM2ViNjA3ODFiMzA3NzlkZjgyZGUy
11
- OTQ3MzlkMzFhMDI5OGI3MjU4M2RlZjU3ZjlkNzM1ODc2YjMwMzU=
9
+ NWNiZTg4MGMyOWNlZjIxMTY3MjE3MzYzZmU2NzQ0OTczYWZkOGExMjkxMzlj
10
+ OWU0NzY1MjBmNjhmNWRiZDY3ODI4NjRhYTY0ZjZiZWUxMzVkNmFhMDdlOWJm
11
+ NWM0MjIxZGEyMzEyY2M2M2I5NmVkZDE0YzcwNTUyYTc4ZmU2OGU=
12
12
  data.tar.gz: !binary |-
13
- ZjY0MjU4YzFiYmUwYjJlNjgyNzYxNzdjYzc0ZDVkZGVjNGI2ZWY5NTcxOWRj
14
- MmI2ODMzM2EyYWM3NzM2YjljZTJiYzE0N2RhMDkxZDUzZTlkODMzMzAzOGQ5
15
- NWQwYjI0YTZlYmZhM2M3NTc2NDNjNzQxNDgwMzEwMjhjMTBhZmM=
13
+ ZTYxYzBjYjM5YzQ4M2UwMWFhMGI0ZTEwNTEyODE1ZmFiNThhMjE2NGU2MmNj
14
+ YzI4YmViZTliNjYwZjA4MzkwYmJjNjg5NTExMDI1Zjc4ZWUwNjE5YThkNzQ3
15
+ MDVjZWVjYzkzODVkZTE1OWU0N2QxZWQ2MTc0NTM4YzA0N2E3NDY=
@@ -0,0 +1,5 @@
1
+ = awscli
2
+
3
+ Amazon Web Service Command Line Interface
4
+
5
+ WIP
@@ -0,0 +1,44 @@
1
+ require 'rake/clean'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+ require 'cucumber'
6
+ require 'cucumber/rake/task'
7
+ Rake::RDocTask.new do |rd|
8
+ rd.main = "README.rdoc"
9
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
10
+ rd.title = 'Your application title'
11
+ end
12
+
13
+ spec = eval(File.read('awscli.gemspec'))
14
+
15
+ Gem::PackageTask.new(spec) do |pkg|
16
+ end
17
+ CUKE_RESULTS = 'results.html'
18
+ CLEAN << CUKE_RESULTS
19
+ desc 'Run features'
20
+ Cucumber::Rake::Task.new(:features) do |t|
21
+ opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
22
+ opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
23
+ t.cucumber_opts = opts
24
+ t.fork = false
25
+ end
26
+
27
+ desc 'Run features tagged as work-in-progress (@wip)'
28
+ Cucumber::Rake::Task.new('features:wip') do |t|
29
+ tag_opts = ' --tags ~@pending'
30
+ tag_opts = ' --tags @wip'
31
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
32
+ t.fork = false
33
+ end
34
+
35
+ task :cucumber => :features
36
+ task 'cucumber:wip' => 'features:wip'
37
+ task :wip => 'features:wip'
38
+ require 'rake/testtask'
39
+ Rake::TestTask.new do |t|
40
+ t.libs << "test"
41
+ t.test_files = FileList['test/*_test.rb']
42
+ end
43
+
44
+ task :default => [:test,:features]
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #Trap interupt to quit cleanly
4
+ Signal.trap("INT") { exit 1 }
5
+
6
+ #load the path if not loaded previously
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') unless $LOAD_PATH.include?(File.dirname(__FILE__) + '/../lib')
8
+
9
+ begin
10
+ require "awscli"
11
+ rescue LoadError
12
+ require "rubygems"
13
+ require "awscli"
14
+ end
15
+
16
+ #Start the cli
17
+ begin
18
+ AwsCli::Cli.start
19
+ rescue Interrupt
20
+ puts "Caught Interrupt, Exiting..."
21
+ rescue Excon::Errors::SocketError
22
+ puts "Error: Establishing Connection to AWS, #{$!}"
23
+ rescue Fog::Compute::AWS::Error
24
+ puts "Error: #{$!}"
25
+ rescue Fog::Compute::AWS::NotFound
26
+ puts "Cannot find Resource: #{$!}"
27
+ rescue Excon::Errors::InternalServerError
28
+ puts "Something went wrong, please try again!."
29
+ puts "Error: #{$!}"
30
+ rescue ArgumentError
31
+ puts "Cannot recognize the argument passed, #{$!}"
32
+ end
@@ -0,0 +1,8 @@
1
+ Feature: My bootstrapped app kinda works
2
+ In order to get going on coding my awesome app
3
+ I want to have aruba and cucumber setup
4
+ So I don't have to do it myself
5
+
6
+ Scenario: App just runs
7
+ When I get help for "awscli"
8
+ Then the exit status should be 0
@@ -0,0 +1,6 @@
1
+ When /^I get help for "([^"]*)"$/ do |app_name|
2
+ @app_name = app_name
3
+ step %(I run `#{app_name} help`)
4
+ end
5
+
6
+ # Add more step definitions here
@@ -0,0 +1,15 @@
1
+ require 'aruba/cucumber'
2
+
3
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
5
+
6
+ Before do
7
+ # Using "announce" causes massive warnings on 1.9.2
8
+ @puts = true
9
+ @original_rubylib = ENV['RUBYLIB']
10
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
11
+ end
12
+
13
+ After do
14
+ ENV['RUBYLIB'] = @original_rubylib
15
+ end
@@ -0,0 +1,51 @@
1
+ #external dependencies
2
+ begin
3
+ require 'thor'
4
+ require 'thor/group'
5
+ require 'fog'
6
+ require 'highline'
7
+ require 'yaml'
8
+ rescue LoadError
9
+ puts "Failed to load gems: fog, highline, thor"
10
+ exit 1
11
+ end
12
+
13
+ module AwsCli
14
+ # => require all interfaces for awscli/
15
+ require 'awscli/version.rb' #to get version
16
+ require 'awscli/errors'
17
+
18
+ # => first require cli so all subcommands can register
19
+ require 'awscli/cli'
20
+ # => register all subcommands
21
+ #EC2
22
+ require 'awscli/cli/ec2'
23
+ require 'awscli/cli/ec2/instances'
24
+ require 'awscli/cli/ec2/ami'
25
+ require 'awscli/cli/ec2/ebs'
26
+ require 'awscli/cli/ec2/eip'
27
+ require 'awscli/cli/ec2/keypairs'
28
+ require 'awscli/cli/ec2/monitoring'
29
+ require 'awscli/cli/ec2/placement'
30
+ require 'awscli/cli/ec2/reservedinstmng'
31
+ require 'awscli/cli/ec2/secgroups'
32
+ require 'awscli/cli/ec2/spot'
33
+ require 'awscli/cli/ec2/tags'
34
+ require 'awscli/cli/ec2/vmmng'
35
+ require 'awscli/cli/ec2/vpc'
36
+ require 'awscli/cli/ec2/vpc/network_acls'
37
+ require 'awscli/cli/ec2/vpc/net_interfaces'
38
+ require 'awscli/cli/ec2/vpc/internet_gateways'
39
+ require 'awscli/cli/ec2/vpc/dhcp'
40
+ #S3
41
+ require 'awscli/cli/s3'
42
+ require 'awscli/cli/s3/files'
43
+ require 'awscli/cli/s3/directories'
44
+ #AS
45
+ require 'awscli/cli/as'
46
+ require 'awscli/cli/as/activities'
47
+ require 'awscli/cli/as/configurations'
48
+ require 'awscli/cli/as/groups'
49
+ require 'awscli/cli/as/instances'
50
+ require 'awscli/cli/as/policies'
51
+ end
@@ -0,0 +1,289 @@
1
+ module Awscli
2
+ module As
3
+
4
+ class Activities
5
+ def initialize connection, options = {}
6
+ @@conn = connection
7
+ end
8
+
9
+ def list options
10
+ if options[:group_name]
11
+ puts @@conn.describe_scaling_activities('AutoScalingGroupName' => options[:group_name]).body['DescribeScalingActivitiesResult']['Activities'].to_yaml
12
+ else
13
+ puts @@conn.describe_scaling_activities.body['DescribeScalingActivitiesResult']['Activities'].to_yaml
14
+ end
15
+ end
16
+ end
17
+
18
+ class Configurations
19
+ def initialize connection, options = {}
20
+ @@conn = connection
21
+ end
22
+
23
+ def list options
24
+ if options[:table]
25
+ @@conn.configurations.table([:id, :instance_type, :key_name, :security_groups])
26
+ else
27
+ puts @@conn.describe_launch_configurations.body['DescribeLaunchConfigurationsResult']['LaunchConfigurations'].to_yaml
28
+ end
29
+ end
30
+
31
+ def create options
32
+ #validate block device mapping and parse it to a hash understandable by fog
33
+ opts = Marshal.load(Marshal.dump(options))
34
+ block_device_mapping = Array.new
35
+ if options[:block_device_mappings]
36
+ options[:block_device_mappings].each do |group|
37
+ mapping = Hash.new
38
+ #parse options
39
+ abort "Invalid block device mapping format, expecting 'devicename=blockdevice' format" unless group =~ /\S=\S/
40
+ device_name, block_device = group.split("=")
41
+ abort "Invalid device name, expectiing '/dev/sd[a-z]'" unless device_name =~ /^\/dev\/sd[a-z]$/
42
+ abort "Invalud block device format, expecting 'ephemeral[0..3]|none|[snapshot-id]:[volume-size]:[true|false]:[standard|io1[:iops]]'" unless block_device =~ /^(snap-.*|ephemeral\w{1,3}|none|:.*)$/
43
+ mapping['DeviceName'] = device_name
44
+ case block_device
45
+ when 'none'
46
+ mapping['Ebs.NoDevice'] = 'true'
47
+ when /ephemeral/
48
+ mapping['VirtualName'] = block_device
49
+ when /snap-.*|:.*/
50
+ snapshot_id, volume_size, delete_on_termination, volume_type, iops = block_device.split(":")
51
+ mapping['Ebs.SnapshotId'] = snapshot_id if !snapshot_id.nil? && !snapshot_id.empty?
52
+ mapping['Ebs.VolumeSize'] = volume_size if !volume_size.nil? && !volume_size.empty?
53
+ mapping['Ebs.DeleteOnTermination'] = delete_on_termination if !delete_on_termination.nil? && !delete_on_termination.empty?
54
+ else
55
+ abort "Cannot validate block_device"
56
+ end
57
+ block_device_mapping << mapping
58
+ end
59
+ end
60
+ if block_devices = opts.delete(:block_device_mappings)
61
+ opts.merge!('BlockDeviceMappings' => block_device_mapping)
62
+ end
63
+ if key_name = opts.delete(:key_name)
64
+ opts.merge!('KeyName' => key_name)
65
+ end
66
+ if sec_grps = opts.delete(:security_groups)
67
+ opts.merge!('SecurityGroups' => sec_grps)
68
+ end
69
+ if spot_price = opts.delete(:spot_price)
70
+ opts.merge!('SpotPrice' => spot_price)
71
+ end
72
+ if user_data = opts.delete(:user_data)
73
+ opts.merge!('UserData' => user_data)
74
+ end
75
+ if instance_monitoring = opts.delete(:instance_monitoring)
76
+ opts.merge!('InstanceMonitoring.Enabled' => instance_monitoring)
77
+ end
78
+ opts.reject! { |k| k == 'image_id' }
79
+ opts.reject! { |k| k == 'instance_type' }
80
+ opts.reject! { |k| k == 'id' }
81
+
82
+ begin
83
+ cfgs = @@conn.create_launch_configuration(options[:image_id], options[:instance_type], options[:id], opts)
84
+ puts "Created Launch Configuration, #{options[:id]}"
85
+ rescue Fog::AWS::AutoScaling::IdentifierTaken
86
+ puts "A launch configuration already exists with the name #{options[:id]}"
87
+ end
88
+ end
89
+
90
+ def delete cfg_name
91
+ cfg = @@conn.configurations.get(cfg_name)
92
+ abort "Cannot find launch configuration with name: #{cfg_name}" unless cfg
93
+ cfg.destroy
94
+ puts "Deleted Launch Configuration with name: #{cfg_name}"
95
+ end
96
+ end
97
+
98
+ class Groups
99
+ def initialize connection, options = {}
100
+ @@conn = connection
101
+ end
102
+
103
+ def list options
104
+ if options[:table]
105
+ @@conn.groups.table([:id, :launch_configuration_name, :desired_capacity, :min_size, :max_size, :vpc_zone_identifier, :termination_policies])
106
+ else
107
+ #yaml dump
108
+ puts @@conn.describe_auto_scaling_groups.body['DescribeAutoScalingGroupsResult']['AutoScalingGroups'].to_yaml
109
+ end
110
+ end
111
+
112
+ def create options
113
+ # => validate & parse options
114
+ opts = Marshal.load(Marshal.dump(options))
115
+ #launch conf name
116
+ abort "Launch configuration name not found: #{options[:launch_configuration_name]}" unless @@conn.configurations.get(options[:launch_configuration_name])
117
+ #remove required options from options hash
118
+ opts.reject! { |k| k == 'id' }
119
+ opts.reject! { |k| k == 'availability_zones' }
120
+ opts.reject! { |k| k == 'launch_configuration_name' }
121
+ opts.reject! { |k| k == 'max_size' }
122
+ opts.reject! { |k| k == 'min_size' }
123
+ if desired_capacity = opts.delete(:desired_capacity)
124
+ opts.merge!('DesiredCapacity' => desired_capacity)
125
+ end
126
+ if default_cooldown = opts.delete(:default_cooldown)
127
+ opts.merge!('DefaultCooldown' => default_cooldown)
128
+ end
129
+ if health_check_grace_period = opts.delete(:health_check_grace_period)
130
+ opts.merge!('HealthCheckGracePeriod' => health_check_grace_period)
131
+ end
132
+ if health_check_type = opts.delete(:health_check_type)
133
+ opts.merge!('HealthCheckType' => health_check_type)
134
+ end
135
+ if load_balancer_names = opts.delete(:load_balancer_names)
136
+ opts.merge!('LoadBalancerNames' => load_balancer_names)
137
+ end
138
+ if placement_group = opts.delete(:placement_group)
139
+ opts.merge!('PlacementGroup' => placement_group)
140
+ end
141
+ if tags = opts.delete(:tags)
142
+ parsed_tags = Array.new
143
+ tags.each do |t|
144
+ abort "Invliad tags format, expecting 'key=value' format" unless t =~ /\S=\S/
145
+ end
146
+ tags.each do |tag|
147
+ parsed_tag = Hash.new
148
+ key, value = tag.split("=")
149
+ parsed_tag['Key'] = key
150
+ parsed_tag['Value'] = value
151
+ parsed_tags << parsed_tag
152
+ end
153
+ opts.merge!('Tags' => parsed_tags)
154
+ end
155
+ if termination_policies = opts.delete(:termination_policies)
156
+ opts.merge!('TerminationPolicies' => termination_policies)
157
+ end
158
+ if vpc_zone_identifiers = opts.delete(:vpc_zone_identifiers)
159
+ opts.merge!('VPCZoneIdentifier' => vpc_zone_identifiers.join(','))
160
+ end
161
+ begin
162
+ @@conn.create_auto_scaling_group(
163
+ options[:id],
164
+ options[:availability_zones],
165
+ options[:launch_configuration_name],
166
+ options[:max_size],
167
+ options[:min_size],
168
+ opts
169
+ )
170
+ puts "Created Auto Scaling Group with name: #{options[:id]}"
171
+ rescue Fog::AWS::AutoScaling::IdentifierTaken
172
+ puts "A auto-scaling-group already exists with the name #{options[:id]}"
173
+ rescue Fog::AWS::AutoScaling::ValidationError
174
+ puts "Validation Error: #{$!}"
175
+ end
176
+ end
177
+
178
+ def set_desired_capacity options
179
+ # => Sets the desired capacity of the auto sacling group
180
+ asg = @@conn.groups.get(options[:id])
181
+ abort "Cannot find Auto Scaling Group with name: #{options[:id]}" unless asg
182
+ min_size = asg.min_size
183
+ max_size = asg.max_size
184
+ abort "Desired capacity should fall in between auto scaling groups min-size: #{min_size} and max-size: #{max_size}" unless options[:desired_capacity].between?(min_size, max_size)
185
+ abort "Desired capacity is already #{asg.desired_capacity}" if options[:desired_capacity] == asg.desired_capacity
186
+ @@conn.set_desired_capacity(options[:id], options[:desired_capacity])
187
+ puts "Scaled Auto Scaling Group: #{options[:id]} to a desired_capacity of #{options[:desired_capacity]}"
188
+ end
189
+
190
+ # def update
191
+ # asg = @@conn.groups.get(options[:id])
192
+ # abort "Cannot find Auto Scaling Group with name: #{options[:id]}" unless asg
193
+ # opts = Marshal.load(Marshal.dump(options))
194
+ # opts.reject! { |k| k == 'id' }
195
+ # asg.update(opts)
196
+ # end
197
+
198
+ def suspend_processes options
199
+ if options[:scaling_processes]
200
+ @@conn.suspend_processes(
201
+ options[:id],
202
+ 'ScalingProcesses' => options[:scaling_processes])
203
+ puts "Suspending processes #{options[:scaling_processes]} for group: #{options[:id]}"
204
+ else
205
+ @@conn.suspend_processes(options[:id])
206
+ puts "Suspending processes for group: #{options[:id]}"
207
+ end
208
+ end
209
+
210
+ def resume_processes options
211
+ if options[:scaling_processes]
212
+ @@conn.resume_processes(
213
+ options[:id],
214
+ 'ScalingProcesses' => options[:scaling_processes]
215
+ )
216
+ puts "Resuming processes #{options[:scaling_processes]} for group: #{options[:id]}"
217
+ else
218
+ @@conn.resume_processes(options[:id])
219
+ puts "Resuming processes for group: #{options[:id]}"
220
+ end
221
+ end
222
+
223
+ def delete options
224
+ begin
225
+ if options[:force]
226
+ @@conn.delete_auto_scaling_group(
227
+ options[:id],
228
+ 'ForceDelete' => options[:force]
229
+ )
230
+ else
231
+ @@conn.delete_auto_scaling_group(options[:id])
232
+ end
233
+ rescue Fog::AWS::AutoScaling::ResourceInUse
234
+ puts "You cannot delete an AutoScalingGroup while there are instances or pending Spot instance request(s) still in the group"
235
+ puts "Use -f option to force delete instances attached to the sacling group"
236
+ exit 1
237
+ end
238
+ puts "Deleted Auto scaling group #{options[:id]}"
239
+ end
240
+ end
241
+
242
+ class Instances
243
+ def initialize connection, options = {}
244
+ @@conn = connection
245
+ end
246
+
247
+ def list
248
+ @@conn.instances.table
249
+ end
250
+
251
+ def terminate instance_id, decrement_capacity
252
+ instance = @@conn.instances.get(instance_id)
253
+ abort "Cannot find instace with id: #{instance_id}" unless instance
254
+ begin
255
+ @@conn.terminate_instance_in_auto_scaling_group(instance_id, decrement_capacity)
256
+ puts "Terminated Instance with id: #{instance_id}"
257
+ puts "Decrement Capacity of the scaling group: #{instance.auto_scaling_group_name} by 1" if decrement_capacity
258
+ rescue Fog::AWS::AutoScaling::ValidationError
259
+ puts "Validation Error: #{$!}"
260
+ end
261
+ end
262
+ end
263
+
264
+ class Policies
265
+ def initialize connection, options = {}
266
+ @@conn = connection
267
+ end
268
+
269
+ def list
270
+ @@conn.policies.table
271
+ end
272
+
273
+ def create options
274
+ @@conn.policies.create(options)
275
+ puts "Created auto sacling policy: #{options[:id]}, for auto scaling group: #{options[:auto_scaling_group_name]}"
276
+ end
277
+
278
+ def destroy name, group_name
279
+ begin
280
+ @@conn.delete_policy(group_name, name)
281
+ puts "Deleted auto scaling policy: #{name}"
282
+ rescue Fog::AWS::AutoScaling::ValidationError
283
+ puts "Validation Error: #{$!}"
284
+ end
285
+ end
286
+ end
287
+
288
+ end
289
+ end