nirvdrum-amazon-ec2 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gitignore +9 -0
  2. data/.yardopts +1 -0
  3. data/ChangeLog +304 -0
  4. data/LICENSE +66 -0
  5. data/README.rdoc +359 -0
  6. data/README_dev.rdoc +10 -0
  7. data/Rakefile +70 -0
  8. data/VERSION +1 -0
  9. data/amazon-ec2.gemspec +142 -0
  10. data/bin/ec2-gem-example.rb +137 -0
  11. data/bin/ec2-gem-profile.rb +10 -0
  12. data/bin/ec2sh +62 -0
  13. data/bin/setup.rb +29 -0
  14. data/deps.rip +1 -0
  15. data/lib/AWS.rb +321 -0
  16. data/lib/AWS/Autoscaling.rb +70 -0
  17. data/lib/AWS/Autoscaling/autoscaling.rb +273 -0
  18. data/lib/AWS/Cloudwatch.rb +32 -0
  19. data/lib/AWS/Cloudwatch/monitoring.rb +80 -0
  20. data/lib/AWS/EC2.rb +33 -0
  21. data/lib/AWS/EC2/availability_zones.rb +29 -0
  22. data/lib/AWS/EC2/console.rb +25 -0
  23. data/lib/AWS/EC2/devpay.rb +18 -0
  24. data/lib/AWS/EC2/elastic_ips.rb +86 -0
  25. data/lib/AWS/EC2/image_attributes.rb +133 -0
  26. data/lib/AWS/EC2/images.rb +117 -0
  27. data/lib/AWS/EC2/instances.rb +234 -0
  28. data/lib/AWS/EC2/keypairs.rb +47 -0
  29. data/lib/AWS/EC2/products.rb +21 -0
  30. data/lib/AWS/EC2/security_groups.rb +164 -0
  31. data/lib/AWS/EC2/snapshots.rb +102 -0
  32. data/lib/AWS/EC2/spot_instance_requests.rb +105 -0
  33. data/lib/AWS/EC2/volumes.rb +100 -0
  34. data/lib/AWS/ELB.rb +71 -0
  35. data/lib/AWS/ELB/load_balancers.rb +178 -0
  36. data/lib/AWS/RDS.rb +73 -0
  37. data/lib/AWS/RDS/rds.rb +522 -0
  38. data/lib/AWS/exceptions.rb +200 -0
  39. data/lib/AWS/responses.rb +21 -0
  40. data/perftools/ec2prof +0 -0
  41. data/perftools/ec2prof-results.dot +132 -0
  42. data/perftools/ec2prof-results.txt +100 -0
  43. data/perftools/ec2prof.symbols +102 -0
  44. data/test/test_Autoscaling_groups.rb +337 -0
  45. data/test/test_EC2.rb +68 -0
  46. data/test/test_EC2_availability_zones.rb +49 -0
  47. data/test/test_EC2_console.rb +54 -0
  48. data/test/test_EC2_elastic_ips.rb +144 -0
  49. data/test/test_EC2_image_attributes.rb +238 -0
  50. data/test/test_EC2_images.rb +229 -0
  51. data/test/test_EC2_instances.rb +611 -0
  52. data/test/test_EC2_keypairs.rb +123 -0
  53. data/test/test_EC2_products.rb +48 -0
  54. data/test/test_EC2_responses.rb +53 -0
  55. data/test/test_EC2_s3_xmlsimple.rb +80 -0
  56. data/test/test_EC2_security_groups.rb +205 -0
  57. data/test/test_EC2_snapshots.rb +83 -0
  58. data/test/test_EC2_spot_instance_requests.rb +178 -0
  59. data/test/test_EC2_volumes.rb +142 -0
  60. data/test/test_ELB_load_balancers.rb +239 -0
  61. data/test/test_RDS.rb +354 -0
  62. data/test/test_helper.rb +23 -0
  63. data/wsdl/2007-08-29.ec2.wsdl +1269 -0
  64. data/wsdl/2008-02-01.ec2.wsdl +1614 -0
  65. data/wsdl/2008-05-05.ec2.wsdl +2052 -0
  66. data/wsdl/2008-12-01.ec2.wsdl +2354 -0
  67. data/wsdl/2009-10-31.ec2.wsdl +4261 -0
  68. data/wsdl/2009-11-30.ec2.wsdl +4668 -0
  69. metadata +199 -0
@@ -0,0 +1,234 @@
1
+ module AWS
2
+ module EC2
3
+ class Base < AWS::Base
4
+
5
+ # Launches a specified number of instances of an AMI for which you have permissions.
6
+ #
7
+ # Amazon API Docs : HTML[http://docs.amazonwebservices.com/AWSEC2/2009-10-31/APIReference/index.html?ApiReference-query-RunInstances.html]
8
+ #
9
+ # @option options [String] :image_id ("") Unique ID of a machine image.
10
+ # @option options [Integer] :min_count (1) Minimum number of instances to launch. If the value is more than Amazon EC2 can launch, no instances are launched at all.
11
+ # @option options [Integer] :max_count (1) Maximum number of instances to launch. If the value is more than Amazon EC2 can launch, the largest possible number above minCount will be launched instead.
12
+ # @option options [optional, String] :key_name (nil) The name of the key pair.
13
+ # @option options [optional, Array of Strings or String] :security_group (nil) Name of the security group(s).
14
+ # @option options [optional, String] :additional_info (nil) Specifies additional information to make available to the instance(s).
15
+ # @option options [optional, String] :user_data (nil) MIME, Base64-encoded user data.
16
+ # @option options [optional, String] :instance_type (nil) Specifies the instance type.
17
+ # @option options [optional, String] :availability_zone (nil) Specifies the placement constraints (Availability Zones) for launching the instances.
18
+ # @option options [optional, String] :kernel_id (nil) The ID of the kernel with which to launch the instance.
19
+ # @option options [optional, String] :ramdisk_id (nil) The ID of the RAM disk with which to launch the instance. Some kernels require additional drivers at launch. Check the kernel requirements for information on whether you need to specify a RAM disk. To find kernel requirements, go to the Resource Center and search for the kernel ID.
20
+ # @option options [optional, Array] :block_device_mapping ([]) An array of Hashes representing the elements of the block device mapping. e.g. [{:device_name => '/dev/sdh', :virtual_name => '', :ebs_snapshot_id => '', :ebs_volume_size => '', :ebs_delete_on_termination => ''},{},...]
21
+ # @option options [optional, Boolean] :monitoring_enabled (false) Enables monitoring for the instance.
22
+ # @option options [optional, String] :subnet_id (nil) Specifies the Amazon VPC subnet ID within which to launch the instance(s) for Amazon Virtual Private Cloud.
23
+ # @option options [optional, Boolean] :disable_api_termination (true) Specifies whether the instance can be terminated using the APIs. You must modify this attribute before you can terminate any "locked" instances from the APIs.
24
+ # @option options [optional, String] :instance_initiated_shutdown_behavior ('stop') Specifies whether the instance's Amazon EBS volumes are stopped or terminated when the instance is shut down. Valid values : 'stop', 'terminate'
25
+ # @option options [optional, Boolean] :base64_encoded (false)
26
+ #
27
+ def run_instances( options = {} )
28
+ options = { :image_id => "",
29
+ :min_count => 1,
30
+ :max_count => 1,
31
+ :base64_encoded => false }.merge(options)
32
+
33
+ raise ArgumentError, ":addressing_type has been deprecated." if options[:addressing_type]
34
+ raise ArgumentError, ":group_id has been deprecated." if options[:group_id]
35
+
36
+ raise ArgumentError, ":image_id must be provided" if options[:image_id].nil? || options[:image_id].empty?
37
+ raise ArgumentError, ":min_count is not valid" unless options[:min_count].to_i > 0
38
+ raise ArgumentError, ":max_count is not valid or must be >= :min_count" unless options[:max_count].to_i > 0 && options[:max_count].to_i >= options[:min_count].to_i
39
+ raise ArgumentError, ":instance_type must specify a valid instance size" unless options[:instance_type].nil? || ["m1.small", "m1.large", "m1.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge"].include?(options[:instance_type])
40
+ raise ArgumentError, ":monitoring_enabled must be 'true' or 'false'" unless options[:monitoring_enabled].nil? || [true, false].include?(options[:monitoring_enabled])
41
+ raise ArgumentError, ":disable_api_termination must be 'true' or 'false'" unless options[:disable_api_termination].nil? || [true, false].include?(options[:disable_api_termination])
42
+ raise ArgumentError, ":instance_initiated_shutdown_behavior must be 'stop' or 'terminate'" unless options[:instance_initiated_shutdown_behavior].nil? || ["stop", "terminate"].include?(options[:instance_initiated_shutdown_behavior])
43
+ raise ArgumentError, ":base64_encoded must be 'true' or 'false'" unless [true, false].include?(options[:base64_encoded])
44
+
45
+ user_data = extract_user_data(options)
46
+
47
+ params = {}
48
+
49
+ if options[:security_group]
50
+ params.merge!(pathlist("SecurityGroup", options[:security_group]))
51
+ end
52
+
53
+ if options[:block_device_mapping]
54
+ params.merge!(pathhashlist('BlockDeviceMapping', options[:block_device_mapping].flatten, {:device_name => 'DeviceName', :virtual_name => 'VirtualName', :ebs_snapshot_id => 'Ebs.SnapshotId', :ebs_volume_size => 'Ebs.VolumeSize', :ebs_delete_on_termination => 'Ebs.DeleteOnTermination' }))
55
+ end
56
+
57
+ params["ImageId"] = options[:image_id]
58
+ params["MinCount"] = options[:min_count].to_s
59
+ params["MaxCount"] = options[:max_count].to_s
60
+ params["KeyName"] = options[:key_name] unless options[:key_name].nil?
61
+ params["AdditionalInfo"] = options[:additional_info] unless options[:additional_info].nil?
62
+ params["UserData"] = user_data unless user_data.nil?
63
+ params["InstanceType"] = options[:instance_type] unless options[:instance_type].nil?
64
+ params["Placement.AvailabilityZone"] = options[:availability_zone] unless options[:availability_zone].nil?
65
+ params["KernelId"] = options[:kernel_id] unless options[:kernel_id].nil?
66
+ params["RamdiskId"] = options[:ramdisk_id] unless options[:ramdisk_id].nil?
67
+ params["Monitoring.Enabled"] = options[:monitoring_enabled].to_s unless options[:monitoring_enabled].nil?
68
+ params["SubnetId"] = options[:subnet_id] unless options[:subnet_id].nil?
69
+ params["DisableApiTermination"] = options[:disable_api_termination].to_s unless options[:disable_api_termination].nil?
70
+ params["InstanceInitiatedShutdownBehavior"] = options[:instance_initiated_shutdown_behavior] unless options[:instance_initiated_shutdown_behavior].nil?
71
+
72
+ return response_generator(:action => "RunInstances", :params => params)
73
+ end
74
+
75
+ # The DescribeInstances operation returns information about instances owned by the user
76
+ # making the request.
77
+ #
78
+ # An optional list of instance IDs may be provided to request information for those instances only. If no
79
+ # instance IDs are provided, information of all relevant instances information will be returned. If an
80
+ # instance is specified that does not exist a fault is returned. If an instance is specified that exists but is not
81
+ # owned by the user making the request, then that instance will not be included in the returned results.
82
+ #
83
+ # Recently terminated instances will be included in the returned results for a small interval subsequent to
84
+ # their termination. This interval is typically of the order of one hour
85
+ #
86
+ # @option options [Array] :instance_id ([])
87
+ #
88
+ def describe_instances( options = {} )
89
+ options = { :instance_id => [] }.merge(options)
90
+ params = pathlist("InstanceId", options[:instance_id])
91
+ return response_generator(:action => "DescribeInstances", :params => params)
92
+ end
93
+
94
+
95
+ # Not yet implemented
96
+ #
97
+ # @todo Implement this method
98
+ #
99
+ def describe_instance_attribute( options = {} )
100
+ raise "Not yet implemented"
101
+ end
102
+
103
+
104
+ # Not yet implemented
105
+ #
106
+ # @todo Implement this method
107
+ #
108
+ def modify_instance_attribute( options = {} )
109
+ raise "Not yet implemented"
110
+ end
111
+
112
+
113
+ # Not yet implemented
114
+ #
115
+ # @todo Implement this method
116
+ #
117
+ def reset_instance_attribute( options = {} )
118
+ raise "Not yet implemented"
119
+ end
120
+
121
+
122
+ # Starts an instance that uses an Amazon EBS volume as its root device.
123
+ #
124
+ # @option options [Array] :instance_id ([]) Array of unique instance ID's of stopped instances.
125
+ #
126
+ def start_instances( options = {} )
127
+ options = { :instance_id => [] }.merge(options)
128
+ raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty?
129
+ params = {}
130
+ params.merge!(pathlist("InstanceId", options[:instance_id]))
131
+ return response_generator(:action => "StartInstances", :params => params)
132
+ end
133
+
134
+
135
+ # Stops an instance that uses an Amazon EBS volume as its root device.
136
+ #
137
+ # @option options [Array] :instance_id ([]) Unique instance ID of a running instance.
138
+ # @option options [optional, Boolean] :force (false) Forces the instance to stop. The instance will not have an opportunity to flush file system caches nor file system meta data. If you use this option, you must perform file system check and repair procedures. This option is not recommended for Windows instances.
139
+ #
140
+ def stop_instances( options = {} )
141
+ options = { :instance_id => [] }.merge(options)
142
+ raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty?
143
+ raise ArgumentError, ":force must be 'true' or 'false'" unless options[:force].nil? || [true, false].include?(options[:force])
144
+ params = {}
145
+ params.merge!(pathlist("InstanceId", options[:instance_id]))
146
+ params["Force"] = options[:force].to_s unless options[:force].nil?
147
+ return response_generator(:action => "StopInstances", :params => params)
148
+ end
149
+
150
+
151
+ # The RebootInstances operation requests a reboot of one or more instances. This operation is
152
+ # asynchronous; it only queues a request to reboot the specified instance(s). The operation will succeed
153
+ # provided the instances are valid and belong to the user. Terminated instances will be ignored.
154
+ #
155
+ # @option options [Array] :instance_id ([])
156
+ #
157
+ def reboot_instances( options = {} )
158
+ options = { :instance_id => [] }.merge(options)
159
+ raise ArgumentError, "No instance IDs provided" if options[:instance_id].nil? || options[:instance_id].empty?
160
+ params = pathlist("InstanceId", options[:instance_id])
161
+ return response_generator(:action => "RebootInstances", :params => params)
162
+ end
163
+
164
+
165
+ # The TerminateInstances operation shuts down one or more instances. This operation is idempotent
166
+ # and terminating an instance that is in the process of shutting down (or already terminated) will succeed.
167
+ # Terminated instances remain visible for a short period of time (approximately one hour) after
168
+ # termination, after which their instance ID is invalidated.
169
+ #
170
+ # @option options [Array] :instance_id ([])
171
+ #
172
+ def terminate_instances( options = {} )
173
+ options = { :instance_id => [] }.merge(options)
174
+ raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty?
175
+ params = pathlist("InstanceId", options[:instance_id])
176
+ return response_generator(:action => "TerminateInstances", :params => params)
177
+ end
178
+
179
+
180
+ # The MonitorInstances operation tells Cloudwatch to begin logging metrics from one or more EC2 instances
181
+ #
182
+ # @option options [Array] :instance_id ([])
183
+ #
184
+ def monitor_instances( options = {} )
185
+ options = { :instance_id => [] }.merge(options)
186
+ raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty?
187
+ params = pathlist("InstanceId", options[:instance_id])
188
+ return response_generator(:action => "MonitorInstances", :params => params)
189
+ end
190
+
191
+
192
+ # The UnmonitorInstances operation tells Cloudwatch to stop logging metrics from one or more EC2 instances
193
+ #
194
+ # @option options [Array] :instance_id ([])
195
+ #
196
+ def unmonitor_instances( options = {} )
197
+ options = { :instance_id => [] }.merge(options)
198
+ raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty?
199
+ params = pathlist("InstanceId", options[:instance_id])
200
+ return response_generator(:action => "UnmonitorInstances", :params => params)
201
+ end
202
+
203
+
204
+ # Not yet implemented
205
+ #
206
+ # @todo Implement this method
207
+ #
208
+ def describe_reserved_instances( options = {} )
209
+ raise "Not yet implemented"
210
+ end
211
+
212
+
213
+ # Not yet implemented
214
+ #
215
+ # @todo Implement this method
216
+ #
217
+ def describe_reserved_instances_offerings( options = {} )
218
+ raise "Not yet implemented"
219
+ end
220
+
221
+
222
+ # Not yet implemented
223
+ #
224
+ # @todo Implement this method
225
+ #
226
+ def purchase_reserved_instances_offering( options = {} )
227
+ raise "Not yet implemented"
228
+ end
229
+
230
+
231
+ end
232
+ end
233
+ end
234
+
@@ -0,0 +1,47 @@
1
+ module AWS
2
+ module EC2
3
+ class Base < AWS::Base
4
+
5
+
6
+ # The CreateKeyPair operation creates a new 2048 bit RSA keypair and returns a unique ID that can be
7
+ # used to reference this keypair when launching new instances.
8
+ #
9
+ # @option options [String] :key_name ("")
10
+ #
11
+ def create_keypair( options = {} )
12
+ options = { :key_name => "" }.merge(options)
13
+ raise ArgumentError, "No :key_name provided" if options[:key_name].nil? || options[:key_name].empty?
14
+ params = { "KeyName" => options[:key_name] }
15
+ return response_generator(:action => "CreateKeyPair", :params => params)
16
+ end
17
+
18
+
19
+ # The DescribeKeyPairs operation returns information about keypairs available for use by the user
20
+ # making the request. Selected keypairs may be specified or the list may be left empty if information for
21
+ # all registered keypairs is required.
22
+ #
23
+ # @option options [Array] :key_name ([])
24
+ #
25
+ def describe_keypairs( options = {} )
26
+ options = { :key_name => [] }.merge(options)
27
+ params = pathlist("KeyName", options[:key_name] )
28
+ return response_generator(:action => "DescribeKeyPairs", :params => params)
29
+ end
30
+
31
+
32
+ # The DeleteKeyPair operation deletes a keypair.
33
+ #
34
+ # @option options [String] :key_name ("")
35
+ #
36
+ def delete_keypair( options = {} )
37
+ options = { :key_name => "" }.merge(options)
38
+ raise ArgumentError, "No :key_name provided" if options[:key_name].nil? || options[:key_name].empty?
39
+ params = { "KeyName" => options[:key_name] }
40
+ return response_generator(:action => "DeleteKeyPair", :params => params)
41
+ end
42
+
43
+
44
+ end
45
+ end
46
+ end
47
+
@@ -0,0 +1,21 @@
1
+ module AWS
2
+ module EC2
3
+ class Base < AWS::Base
4
+
5
+ # The ConfirmProductInstance operation returns true if the given product code is attached to the instance
6
+ # with the given instance id. False is returned if the product code is not attached to the instance.
7
+ #
8
+ # @option options [String] :product_code ("")
9
+ # @option options [String] :instance_id ("")
10
+ #
11
+ def confirm_product_instance( options ={} )
12
+ options = {:product_code => "", :instance_id => ""}.merge(options)
13
+ raise ArgumentError, "No product code provided" if options[:product_code].nil? || options[:product_code].empty?
14
+ raise ArgumentError, "No instance ID provided" if options[:instance_id].nil? || options[:instance_id].empty?
15
+ params = { "ProductCode" => options[:product_code], "InstanceId" => options[:instance_id] }
16
+ return response_generator(:action => "ConfirmProductInstance", :params => params)
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,164 @@
1
+ module AWS
2
+ module EC2
3
+ class Base < AWS::Base
4
+
5
+
6
+ # The CreateSecurityGroup operation creates a new security group. Every instance is launched
7
+ # in a security group. If none is specified as part of the launch request then instances
8
+ # are launched in the default security group. Instances within the same security group have
9
+ # unrestricted network access to one another. Instances will reject network access attempts from other
10
+ # instances in a different security group. As the owner of instances you may grant or revoke specific
11
+ # permissions using the AuthorizeSecurityGroupIngress and RevokeSecurityGroupIngress operations.
12
+ #
13
+ # @option options [String] :group_name ("")
14
+ # @option options [String] :group_description ("")
15
+ #
16
+ def create_security_group( options = {} )
17
+ options = {:group_name => "",
18
+ :group_description => ""
19
+ }.merge(options)
20
+ raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty?
21
+ raise ArgumentError, "No :group_description provided" if options[:group_description].nil? || options[:group_description].empty?
22
+ params = {
23
+ "GroupName" => options[:group_name],
24
+ "GroupDescription" => options[:group_description]
25
+ }
26
+ return response_generator(:action => "CreateSecurityGroup", :params => params)
27
+ end
28
+
29
+
30
+ # The DescribeSecurityGroups operation returns information about security groups owned by the
31
+ # user making the request.
32
+ #
33
+ # An optional list of security group names may be provided to request information for those security
34
+ # groups only. If no security group names are provided, information of all security groups will be
35
+ # returned. If a group is specified that does not exist an exception is returned.
36
+ #
37
+ # @option options [optional, Array] :group_name ([])
38
+ #
39
+ def describe_security_groups( options = {} )
40
+ options = { :group_name => [] }.merge(options)
41
+ params = pathlist("GroupName", options[:group_name] )
42
+ return response_generator(:action => "DescribeSecurityGroups", :params => params)
43
+ end
44
+
45
+
46
+ # The DeleteSecurityGroup operation deletes a security group.
47
+ #
48
+ # If an attempt is made to delete a security group and any instances exist that are members of that group a
49
+ # fault is returned.
50
+ #
51
+ # @option options [String] :group_name ("")
52
+ #
53
+ def delete_security_group( options = {} )
54
+ options = { :group_name => "" }.merge(options)
55
+ raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty?
56
+ params = { "GroupName" => options[:group_name] }
57
+ return response_generator(:action => "DeleteSecurityGroup", :params => params)
58
+ end
59
+
60
+
61
+ # The AuthorizeSecurityGroupIngress operation adds permissions to a security group.
62
+ #
63
+ # Permissions are specified in terms of the IP protocol (TCP, UDP or ICMP), the source of the request (by
64
+ # IP range or an Amazon EC2 user-group pair), source and destination port ranges (for TCP and UDP),
65
+ # and ICMP codes and types (for ICMP). When authorizing ICMP, -1 may be used as a wildcard in the
66
+ # type and code fields.
67
+ #
68
+ # Permission changes are propagated to instances within the security group being modified as quickly as
69
+ # possible. However, a small delay is likely, depending on the number of instances that are members of
70
+ # the indicated group.
71
+ #
72
+ # When authorizing a user/group pair permission, GroupName, SourceSecurityGroupName and
73
+ # SourceSecurityGroupOwnerId must be specified. When authorizing a CIDR IP permission,
74
+ # GroupName, IpProtocol, FromPort, ToPort and CidrIp must be specified. Mixing these two types
75
+ # of parameters is not allowed.
76
+ #
77
+ # @option options [String] :group_name ("")
78
+ # @option options [optional, String] :ip_protocol (nil) Required when authorizing CIDR IP permission
79
+ # @option options [optional, Integer] :from_port (nil) Required when authorizing CIDR IP permission
80
+ # @option options [optional, Integer] :to_port (nil) Required when authorizing CIDR IP permission
81
+ # @option options [optional, String] :cidr_ip (nil) Required when authorizing CIDR IP permission
82
+ # @option options [optional, String] :source_security_group_name (nil) Required when authorizing user group pair permissions
83
+ # @option options [optional, String] :source_security_group_owner_id (nil) Required when authorizing user group pair permissions
84
+ #
85
+ def authorize_security_group_ingress( options = {} )
86
+ options = { :group_name => nil,
87
+ :ip_protocol => nil,
88
+ :from_port => nil,
89
+ :to_port => nil,
90
+ :cidr_ip => nil,
91
+ :source_security_group_name => nil,
92
+ :source_security_group_owner_id => nil }.merge(options)
93
+
94
+ # lets not validate the rest of the possible permutations of required params and instead let
95
+ # EC2 sort it out on the server side. We'll only require :group_name as that is always needed.
96
+ raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty?
97
+
98
+ params = { "GroupName" => options[:group_name],
99
+ "IpProtocol" => options[:ip_protocol],
100
+ "FromPort" => options[:from_port].to_s,
101
+ "ToPort" => options[:to_port].to_s,
102
+ "CidrIp" => options[:cidr_ip],
103
+ "SourceSecurityGroupName" => options[:source_security_group_name],
104
+ "SourceSecurityGroupOwnerId" => options[:source_security_group_owner_id]
105
+ }
106
+ return response_generator(:action => "AuthorizeSecurityGroupIngress", :params => params)
107
+ end
108
+
109
+
110
+ # The RevokeSecurityGroupIngress operation revokes existing permissions that were previously
111
+ # granted to a security group. The permissions to revoke must be specified using the same values
112
+ # originally used to grant the permission.
113
+ #
114
+ # Permissions are specified in terms of the IP protocol (TCP, UDP or ICMP), the source of the request (by
115
+ # IP range or an Amazon EC2 user-group pair), source and destination port ranges (for TCP and UDP),
116
+ # and ICMP codes and types (for ICMP). When authorizing ICMP, -1 may be used as a wildcard in the
117
+ # type and code fields.
118
+ #
119
+ # Permission changes are propagated to instances within the security group being modified as quickly as
120
+ # possible. However, a small delay is likely, depending on the number of instances that are members of
121
+ # the indicated group.
122
+ #
123
+ # When revoking a user/group pair permission, GroupName, SourceSecurityGroupName and
124
+ # SourceSecurityGroupOwnerId must be specified. When authorizing a CIDR IP permission,
125
+ # GroupName, IpProtocol, FromPort, ToPort and CidrIp must be specified. Mixing these two types
126
+ # of parameters is not allowed.
127
+ #
128
+ # @option options [String] :group_name ("")
129
+ # @option options [optional, String] :ip_protocol (nil) Required when revoking CIDR IP permission
130
+ # @option options [optional, Integer] :from_port (nil) Required when revoking CIDR IP permission
131
+ # @option options [optional, Integer] :to_port (nil) Required when revoking CIDR IP permission
132
+ # @option options [optional, String] :cidr_ip (nil) Required when revoking CIDR IP permission
133
+ # @option options [optional, String] :source_security_group_name (nil) Required when revoking user group pair permissions
134
+ # @option options [optional, String] :source_security_group_owner_id (nil) Required when revoking user group pair permissions
135
+ #
136
+ def revoke_security_group_ingress( options = {} )
137
+ options = { :group_name => nil,
138
+ :ip_protocol => nil,
139
+ :from_port => nil,
140
+ :to_port => nil,
141
+ :cidr_ip => nil,
142
+ :source_security_group_name => nil,
143
+ :source_security_group_owner_id => nil }.merge(options)
144
+
145
+ # lets not validate the rest of the possible permutations of required params and instead let
146
+ # EC2 sort it out on the server side. We'll only require :group_name as that is always needed.
147
+ raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty?
148
+
149
+ params = { "GroupName" => options[:group_name],
150
+ "IpProtocol" => options[:ip_protocol],
151
+ "FromPort" => options[:from_port].to_s,
152
+ "ToPort" => options[:to_port].to_s,
153
+ "CidrIp" => options[:cidr_ip],
154
+ "SourceSecurityGroupName" => options[:source_security_group_name],
155
+ "SourceSecurityGroupOwnerId" => options[:source_security_group_owner_id]
156
+ }
157
+ return response_generator(:action => "RevokeSecurityGroupIngress", :params => params)
158
+ end
159
+
160
+
161
+ end
162
+ end
163
+ end
164
+