newrelic-amazon-ec2 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.yardopts +1 -0
- data/ChangeLog +293 -0
- data/LICENSE +66 -0
- data/README.rdoc +354 -0
- data/README_dev.rdoc +12 -0
- data/Rakefile +101 -0
- data/VERSION +1 -0
- data/amazon-ec2.gemspec +134 -0
- data/bin/ec2-gem-example.rb +137 -0
- data/bin/ec2-gem-profile.rb +10 -0
- data/bin/ec2sh +62 -0
- data/bin/setup.rb +28 -0
- data/deps.rip +1 -0
- data/lib/AWS.rb +292 -0
- data/lib/AWS/Autoscaling.rb +70 -0
- data/lib/AWS/Autoscaling/autoscaling.rb +273 -0
- data/lib/AWS/Cloudwatch.rb +32 -0
- data/lib/AWS/Cloudwatch/monitoring.rb +89 -0
- data/lib/AWS/EC2.rb +33 -0
- data/lib/AWS/EC2/availability_zones.rb +21 -0
- data/lib/AWS/EC2/console.rb +23 -0
- data/lib/AWS/EC2/elastic_ips.rb +81 -0
- data/lib/AWS/EC2/image_attributes.rb +133 -0
- data/lib/AWS/EC2/images.rb +101 -0
- data/lib/AWS/EC2/instances.rb +212 -0
- data/lib/AWS/EC2/keypairs.rb +61 -0
- data/lib/AWS/EC2/products.rb +21 -0
- data/lib/AWS/EC2/security_groups.rb +183 -0
- data/lib/AWS/EC2/snapshots.rb +59 -0
- data/lib/AWS/EC2/volumes.rb +115 -0
- data/lib/AWS/ELB.rb +71 -0
- data/lib/AWS/ELB/load_balancers.rb +178 -0
- data/lib/AWS/exceptions.rb +122 -0
- data/lib/AWS/responses.rb +21 -0
- data/newrelic-amazon-ec2.gemspec +136 -0
- data/perftools/ec2prof +0 -0
- data/perftools/ec2prof-results.dot +132 -0
- data/perftools/ec2prof-results.txt +100 -0
- data/perftools/ec2prof.symbols +102 -0
- data/test/test_Autoscaling_groups.rb +336 -0
- data/test/test_EC2.rb +68 -0
- data/test/test_EC2_availability_zones.rb +49 -0
- data/test/test_EC2_console.rb +54 -0
- data/test/test_EC2_elastic_ips.rb +144 -0
- data/test/test_EC2_image_attributes.rb +238 -0
- data/test/test_EC2_images.rb +197 -0
- data/test/test_EC2_instances.rb +429 -0
- data/test/test_EC2_keypairs.rb +123 -0
- data/test/test_EC2_products.rb +48 -0
- data/test/test_EC2_responses.rb +53 -0
- data/test/test_EC2_s3_xmlsimple.rb +80 -0
- data/test/test_EC2_security_groups.rb +205 -0
- data/test/test_EC2_snapshots.rb +83 -0
- data/test/test_EC2_volumes.rb +142 -0
- data/test/test_ELB_load_balancers.rb +239 -0
- data/test/test_helper.rb +23 -0
- data/wsdl/2007-08-29.ec2.wsdl +1269 -0
- data/wsdl/2008-02-01.ec2.wsdl +1614 -0
- data/wsdl/2008-05-05.ec2.wsdl +2052 -0
- data/wsdl/2008-12-01.ec2.wsdl +2354 -0
- metadata +218 -0
@@ -0,0 +1,212 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
|
4
|
+
class Base < AWS::Base
|
5
|
+
|
6
|
+
# The RunInstances operation launches a specified number of instances.
|
7
|
+
#
|
8
|
+
# Note : The Query version of RunInstances only allows instances of a single AMI to be launched in
|
9
|
+
# one call. This is different from the SOAP API call of the same name but similar to the
|
10
|
+
# ec2-run-instances command line tool.
|
11
|
+
#
|
12
|
+
# If Amazon EC2 cannot launch the minimum number AMIs you request, no instances launch. If there
|
13
|
+
# is insufficient capacity to launch the maximum number of AMIs you request, Amazon EC2 launches
|
14
|
+
# as many as possible to satisfy the requested maximum values.
|
15
|
+
#
|
16
|
+
# Every instance is launched in a security group. If you do not specify a security group at
|
17
|
+
# launch, the instances start in the default security group.
|
18
|
+
#
|
19
|
+
# An optional instance type can be specified. Currently supported types are 'm1.small', 'm1.large',
|
20
|
+
# 'm1.xlarge' and the high CPU types 'c1.medium' and 'c1.xlarge'. 'm1.small' is the default
|
21
|
+
# if no instance_type is specified.
|
22
|
+
#
|
23
|
+
# You can provide an optional key pair ID for each image in the launch request. All instances
|
24
|
+
# that are created from images that use this key pair will have access to the associated public
|
25
|
+
# key at boot. You can use this key to provide secure access to an instance of an image on a
|
26
|
+
# per-instance basis. Amazon EC2 public images use this feature to provide secure access
|
27
|
+
# without passwords.
|
28
|
+
#
|
29
|
+
# Important! Launching public images without a key pair ID will leave them inaccessible.
|
30
|
+
#
|
31
|
+
# The public key material is made available to the instance at boot time by placing it in a file named
|
32
|
+
# openssh_id.pub on a logical device that is exposed to the instance as /dev/sda2 (the ephemeral
|
33
|
+
# store). The format of this file is suitable for use as an entry within ~/.ssh/authorized_keys (the
|
34
|
+
# OpenSSH format). This can be done at boot time (as part of rclocal, for example) allowing for secure
|
35
|
+
# password-less access.
|
36
|
+
#
|
37
|
+
# Optional user data can be provided in the launch request. All instances comprising the launch
|
38
|
+
# request have access to this data (see Instance Metadata for details).
|
39
|
+
#
|
40
|
+
# If any of the AMIs have product codes attached for which the user has not subscribed,
|
41
|
+
# the RunInstances call will fail.
|
42
|
+
#
|
43
|
+
# @option options [String] :image_id ("")
|
44
|
+
# @option options [Integer] :min_count (1)
|
45
|
+
# @option options [Integer] :max_count (1)
|
46
|
+
# @option options [optional, String] :key_name (nil)
|
47
|
+
# @option options [optional, Array] :group_id ([])
|
48
|
+
# @option options [optional, String] :user_data (nil)
|
49
|
+
# @option options [optional, String] :addressing_type ("public")
|
50
|
+
# @option options [optional, String] :instance_type ("m1.small")
|
51
|
+
# @option options [optional, String] :kernel_id (nil)
|
52
|
+
# @option options [optional, String] :availability_zone (nil)
|
53
|
+
# @option options [optional, Boolean] :base64_encoded (false)
|
54
|
+
#
|
55
|
+
def run_instances( options = {} )
|
56
|
+
|
57
|
+
options = { :image_id => "",
|
58
|
+
:min_count => 1,
|
59
|
+
:max_count => 1,
|
60
|
+
:key_name => nil,
|
61
|
+
:group_id => [],
|
62
|
+
:user_data => nil,
|
63
|
+
:addressing_type => "public",
|
64
|
+
:instance_type => "m1.small",
|
65
|
+
:kernel_id => nil,
|
66
|
+
:availability_zone => nil,
|
67
|
+
:base64_encoded => false }.merge(options)
|
68
|
+
|
69
|
+
# Do some validation on the arguments provided
|
70
|
+
raise ArgumentError, ":image_id must be provided" if options[:image_id].nil? || options[:image_id].empty?
|
71
|
+
raise ArgumentError, ":min_count is not valid" unless options[:min_count].to_i > 0
|
72
|
+
raise ArgumentError, ":max_count is not valid" unless options[:max_count].to_i > 0
|
73
|
+
raise ArgumentError, ":addressing_type must be 'direct' or 'public'" unless options[:addressing_type] == "public" || options[:addressing_type] == "direct"
|
74
|
+
raise ArgumentError, ":instance_type must be 'm1.small', 'm1.large', 'm1.xlarge', 'c1.medium', or 'c1.xlarge'" unless options[:instance_type] == "m1.small" || options[:instance_type] == "m1.large" || options[:instance_type] == "m1.xlarge" || options[:instance_type] == "c1.medium" || options[:instance_type] == "c1.xlarge"
|
75
|
+
raise ArgumentError, ":base64_encoded must be 'true' or 'false'" unless options[:base64_encoded] == true || options[:base64_encoded] == false
|
76
|
+
|
77
|
+
user_data = extract_user_data(options)
|
78
|
+
|
79
|
+
params = {
|
80
|
+
"ImageId" => options[:image_id],
|
81
|
+
"MinCount" => options[:min_count].to_s,
|
82
|
+
"MaxCount" => options[:max_count].to_s,
|
83
|
+
}.merge(pathlist("SecurityGroup", options[:group_id]))
|
84
|
+
|
85
|
+
params["KeyName"] = options[:key_name] unless options[:key_name].nil?
|
86
|
+
params["UserData"] = user_data unless user_data.nil?
|
87
|
+
params["AddressingType"] = options[:addressing_type]
|
88
|
+
params["InstanceType"] = options[:instance_type]
|
89
|
+
params["KernelId"] = options[:kernel_id] unless options[:kernel_id].nil?
|
90
|
+
params["Placement.AvailabilityZone"] = options[:availability_zone] unless options[:availability_zone].nil?
|
91
|
+
|
92
|
+
return response_generator(:action => "RunInstances", :params => params)
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
# If :user_data is passed in then URL escape and Base64 encode it
|
97
|
+
# as needed. Need for URL Escape + Base64 encoding is determined
|
98
|
+
# by :base64_encoded param.
|
99
|
+
def extract_user_data( options = {} )
|
100
|
+
return unless options[:user_data]
|
101
|
+
if options[:user_data]
|
102
|
+
if options[:base64_encoded]
|
103
|
+
Base64.encode64(options[:user_data]).gsub(/\n/,"").strip()
|
104
|
+
else
|
105
|
+
options[:user_data]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
# The DescribeInstances operation returns information about instances owned by the user
|
112
|
+
# making the request.
|
113
|
+
#
|
114
|
+
# An optional list of instance IDs may be provided to request information for those instances only. If no
|
115
|
+
# instance IDs are provided, information of all relevant instances information will be returned. If an
|
116
|
+
# instance is specified that does not exist a fault is returned. If an instance is specified that exists but is not
|
117
|
+
# owned by the user making the request, then that instance will not be included in the returned results.
|
118
|
+
#
|
119
|
+
# Recently terminated instances will be included in the returned results for a small interval subsequent to
|
120
|
+
# their termination. This interval is typically of the order of one hour
|
121
|
+
#
|
122
|
+
# @option options [Array] :instance_id ([])
|
123
|
+
#
|
124
|
+
def describe_instances( options = {} )
|
125
|
+
|
126
|
+
options = { :instance_id => [] }.merge(options)
|
127
|
+
|
128
|
+
params = pathlist("InstanceId", options[:instance_id])
|
129
|
+
|
130
|
+
return response_generator(:action => "DescribeInstances", :params => params)
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
# The RebootInstances operation requests a reboot of one or more instances. This operation is
|
136
|
+
# asynchronous; it only queues a request to reboot the specified instance(s). The operation will succeed
|
137
|
+
# provided the instances are valid and belong to the user. Terminated instances will be ignored.
|
138
|
+
#
|
139
|
+
# @option options [Array] :instance_id ([])
|
140
|
+
#
|
141
|
+
def reboot_instances( options = {} )
|
142
|
+
|
143
|
+
# defaults
|
144
|
+
options = { :instance_id => [] }.merge(options)
|
145
|
+
|
146
|
+
raise ArgumentError, "No instance IDs provided" if options[:instance_id].nil? || options[:instance_id].empty?
|
147
|
+
|
148
|
+
params = pathlist("InstanceId", options[:instance_id])
|
149
|
+
|
150
|
+
return response_generator(:action => "RebootInstances", :params => params)
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
# The TerminateInstances operation shuts down one or more instances. This operation is idempotent
|
156
|
+
# and terminating an instance that is in the process of shutting down (or already terminated) will succeed.
|
157
|
+
# Terminated instances remain visible for a short period of time (approximately one hour) after
|
158
|
+
# termination, after which their instance ID is invalidated.
|
159
|
+
#
|
160
|
+
# @option options [Array] :instance_id ([])
|
161
|
+
#
|
162
|
+
def terminate_instances( options = {} )
|
163
|
+
|
164
|
+
options = { :instance_id => [] }.merge(options)
|
165
|
+
|
166
|
+
raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty?
|
167
|
+
|
168
|
+
params = pathlist("InstanceId", options[:instance_id])
|
169
|
+
|
170
|
+
return response_generator(:action => "TerminateInstances", :params => params)
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
# The MonitorInstances operation tells Cloudwatch to begin logging metrics from one or more EC2 instances
|
176
|
+
#
|
177
|
+
# @option options [Array] :instance_id ([])
|
178
|
+
#
|
179
|
+
def monitor_instances( options = {} )
|
180
|
+
|
181
|
+
options = { :instance_id => [] }.merge(options)
|
182
|
+
|
183
|
+
raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty?
|
184
|
+
|
185
|
+
params = pathlist("InstanceId", options[:instance_id])
|
186
|
+
|
187
|
+
return response_generator(:action => "MonitorInstances", :params => params)
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
# The UnmonitorInstances operation tells Cloudwatch to stop logging metrics from one or more EC2 instances
|
194
|
+
#
|
195
|
+
# @option options [Array] :instance_id ([])
|
196
|
+
#
|
197
|
+
def unmonitor_instances( options = {} )
|
198
|
+
|
199
|
+
options = { :instance_id => [] }.merge(options)
|
200
|
+
|
201
|
+
raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty?
|
202
|
+
|
203
|
+
params = pathlist("InstanceId", options[:instance_id])
|
204
|
+
|
205
|
+
return response_generator(:action => "UnmonitorInstances", :params => params)
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
|
4
|
+
class Base < AWS::Base
|
5
|
+
|
6
|
+
|
7
|
+
# The CreateKeyPair operation creates a new 2048 bit RSA keypair and returns a unique ID that can be
|
8
|
+
# used to reference this keypair when launching new instances.
|
9
|
+
#
|
10
|
+
# @option options [String] :key_name ("")
|
11
|
+
#
|
12
|
+
def create_keypair( options = {} )
|
13
|
+
|
14
|
+
options = { :key_name => "" }.merge(options)
|
15
|
+
|
16
|
+
raise ArgumentError, "No :key_name provided" if options[:key_name].nil? || options[:key_name].empty?
|
17
|
+
|
18
|
+
params = { "KeyName" => options[:key_name] }
|
19
|
+
|
20
|
+
return response_generator(:action => "CreateKeyPair", :params => params)
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# The DescribeKeyPairs operation returns information about keypairs available for use by the user
|
26
|
+
# making the request. Selected keypairs may be specified or the list may be left empty if information for
|
27
|
+
# all registered keypairs is required.
|
28
|
+
#
|
29
|
+
# @option options [Array] :key_name ([])
|
30
|
+
#
|
31
|
+
def describe_keypairs( options = {} )
|
32
|
+
|
33
|
+
options = { :key_name => [] }.merge(options)
|
34
|
+
|
35
|
+
params = pathlist("KeyName", options[:key_name] )
|
36
|
+
|
37
|
+
return response_generator(:action => "DescribeKeyPairs", :params => params)
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# The DeleteKeyPair operation deletes a keypair.
|
43
|
+
#
|
44
|
+
# @option options [String] :key_name ("")
|
45
|
+
#
|
46
|
+
def delete_keypair( options = {} )
|
47
|
+
|
48
|
+
options = { :key_name => "" }.merge(options)
|
49
|
+
|
50
|
+
raise ArgumentError, "No :key_name provided" if options[:key_name].nil? || options[:key_name].empty?
|
51
|
+
|
52
|
+
params = { "KeyName" => options[:key_name] }
|
53
|
+
|
54
|
+
return response_generator(:action => "DeleteKeyPair", :params => params)
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -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,183 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
class Base < AWS::Base
|
4
|
+
|
5
|
+
# The CreateSecurityGroup operation creates a new security group. Every instance is launched
|
6
|
+
# in a security group. If none is specified as part of the launch request then instances
|
7
|
+
# are launched in the default security group. Instances within the same security group have
|
8
|
+
# unrestricted network access to one another. Instances will reject network access attempts from other
|
9
|
+
# instances in a different security group. As the owner of instances you may grant or revoke specific
|
10
|
+
# permissions using the AuthorizeSecurityGroupIngress and RevokeSecurityGroupIngress operations.
|
11
|
+
#
|
12
|
+
# @option options [String] :group_name ("")
|
13
|
+
# @option options [String] :group_description ("")
|
14
|
+
#
|
15
|
+
def create_security_group( options = {} )
|
16
|
+
|
17
|
+
options = {:group_name => "",
|
18
|
+
:group_description => ""
|
19
|
+
}.merge(options)
|
20
|
+
|
21
|
+
raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty?
|
22
|
+
raise ArgumentError, "No :group_description provided" if options[:group_description].nil? || options[:group_description].empty?
|
23
|
+
|
24
|
+
params = {
|
25
|
+
"GroupName" => options[:group_name],
|
26
|
+
"GroupDescription" => options[:group_description]
|
27
|
+
}
|
28
|
+
|
29
|
+
return response_generator(:action => "CreateSecurityGroup", :params => params)
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
# The DescribeSecurityGroups operation returns information about security groups owned by the
|
35
|
+
# user making the request.
|
36
|
+
#
|
37
|
+
# An optional list of security group names may be provided to request information for those security
|
38
|
+
# groups only. If no security group names are provided, information of all security groups will be
|
39
|
+
# returned. If a group is specified that does not exist an exception is returned.
|
40
|
+
#
|
41
|
+
# @option options [optional, Array] :group_name ([])
|
42
|
+
#
|
43
|
+
def describe_security_groups( options = {} )
|
44
|
+
|
45
|
+
options = { :group_name => [] }.merge(options)
|
46
|
+
|
47
|
+
params = pathlist("GroupName", options[:group_name] )
|
48
|
+
|
49
|
+
return response_generator(:action => "DescribeSecurityGroups", :params => params)
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
# The DeleteSecurityGroup operation deletes a security group.
|
55
|
+
#
|
56
|
+
# If an attempt is made to delete a security group and any instances exist that are members of that group a
|
57
|
+
# fault is returned.
|
58
|
+
#
|
59
|
+
# @option options [String] :group_name ("")
|
60
|
+
#
|
61
|
+
def delete_security_group( options = {} )
|
62
|
+
|
63
|
+
options = { :group_name => "" }.merge(options)
|
64
|
+
|
65
|
+
raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty?
|
66
|
+
|
67
|
+
params = { "GroupName" => options[:group_name] }
|
68
|
+
|
69
|
+
return response_generator(:action => "DeleteSecurityGroup", :params => params)
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
# The AuthorizeSecurityGroupIngress operation adds permissions to a security group.
|
75
|
+
#
|
76
|
+
# Permissions are specified in terms of the IP protocol (TCP, UDP or ICMP), the source of the request (by
|
77
|
+
# IP range or an Amazon EC2 user-group pair), source and destination port ranges (for TCP and UDP),
|
78
|
+
# and ICMP codes and types (for ICMP). When authorizing ICMP, -1 may be used as a wildcard in the
|
79
|
+
# type and code fields.
|
80
|
+
#
|
81
|
+
# Permission changes are propagated to instances within the security group being modified as quickly as
|
82
|
+
# possible. However, a small delay is likely, depending on the number of instances that are members of
|
83
|
+
# the indicated group.
|
84
|
+
#
|
85
|
+
# When authorizing a user/group pair permission, GroupName, SourceSecurityGroupName and
|
86
|
+
# SourceSecurityGroupOwnerId must be specified. When authorizing a CIDR IP permission,
|
87
|
+
# GroupName, IpProtocol, FromPort, ToPort and CidrIp must be specified. Mixing these two types
|
88
|
+
# of parameters is not allowed.
|
89
|
+
#
|
90
|
+
# @option options [String] :group_name ("")
|
91
|
+
# @option options [optional, String] :ip_protocol (nil) Required when authorizing CIDR IP permission
|
92
|
+
# @option options [optional, Integer] :from_port (nil) Required when authorizing CIDR IP permission
|
93
|
+
# @option options [optional, Integer] :to_port (nil) Required when authorizing CIDR IP permission
|
94
|
+
# @option options [optional, String] :cidr_ip (nil) Required when authorizing CIDR IP permission
|
95
|
+
# @option options [optional, String] :source_security_group_name (nil) Required when authorizing user group pair permissions
|
96
|
+
# @option options [optional, String] :source_security_group_owner_id (nil) Required when authorizing user group pair permissions
|
97
|
+
#
|
98
|
+
def authorize_security_group_ingress( options = {} )
|
99
|
+
|
100
|
+
# defaults
|
101
|
+
options = { :group_name => nil,
|
102
|
+
:ip_protocol => nil,
|
103
|
+
:from_port => nil,
|
104
|
+
:to_port => nil,
|
105
|
+
:cidr_ip => nil,
|
106
|
+
:source_security_group_name => nil,
|
107
|
+
:source_security_group_owner_id => nil }.merge(options)
|
108
|
+
|
109
|
+
# lets not validate the rest of the possible permutations of required params and instead let
|
110
|
+
# EC2 sort it out on the server side. We'll only require :group_name as that is always needed.
|
111
|
+
raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty?
|
112
|
+
|
113
|
+
params = { "GroupName" => options[:group_name],
|
114
|
+
"IpProtocol" => options[:ip_protocol],
|
115
|
+
"FromPort" => options[:from_port].to_s,
|
116
|
+
"ToPort" => options[:to_port].to_s,
|
117
|
+
"CidrIp" => options[:cidr_ip],
|
118
|
+
"SourceSecurityGroupName" => options[:source_security_group_name],
|
119
|
+
"SourceSecurityGroupOwnerId" => options[:source_security_group_owner_id]
|
120
|
+
}
|
121
|
+
|
122
|
+
return response_generator(:action => "AuthorizeSecurityGroupIngress", :params => params)
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
# The RevokeSecurityGroupIngress operation revokes existing permissions that were previously
|
128
|
+
# granted to a security group. The permissions to revoke must be specified using the same values
|
129
|
+
# originally used to grant the permission.
|
130
|
+
#
|
131
|
+
# Permissions are specified in terms of the IP protocol (TCP, UDP or ICMP), the source of the request (by
|
132
|
+
# IP range or an Amazon EC2 user-group pair), source and destination port ranges (for TCP and UDP),
|
133
|
+
# and ICMP codes and types (for ICMP). When authorizing ICMP, -1 may be used as a wildcard in the
|
134
|
+
# type and code fields.
|
135
|
+
#
|
136
|
+
# Permission changes are propagated to instances within the security group being modified as quickly as
|
137
|
+
# possible. However, a small delay is likely, depending on the number of instances that are members of
|
138
|
+
# the indicated group.
|
139
|
+
#
|
140
|
+
# When revoking a user/group pair permission, GroupName, SourceSecurityGroupName and
|
141
|
+
# SourceSecurityGroupOwnerId must be specified. When authorizing a CIDR IP permission,
|
142
|
+
# GroupName, IpProtocol, FromPort, ToPort and CidrIp must be specified. Mixing these two types
|
143
|
+
# of parameters is not allowed.
|
144
|
+
#
|
145
|
+
# @option options [String] :group_name ("")
|
146
|
+
# @option options [optional, String] :ip_protocol (nil) Required when revoking CIDR IP permission
|
147
|
+
# @option options [optional, Integer] :from_port (nil) Required when revoking CIDR IP permission
|
148
|
+
# @option options [optional, Integer] :to_port (nil) Required when revoking CIDR IP permission
|
149
|
+
# @option options [optional, String] :cidr_ip (nil) Required when revoking CIDR IP permission
|
150
|
+
# @option options [optional, String] :source_security_group_name (nil) Required when revoking user group pair permissions
|
151
|
+
# @option options [optional, String] :source_security_group_owner_id (nil) Required when revoking user group pair permissions
|
152
|
+
#
|
153
|
+
def revoke_security_group_ingress( options = {} )
|
154
|
+
|
155
|
+
# defaults
|
156
|
+
options = { :group_name => nil,
|
157
|
+
:ip_protocol => nil,
|
158
|
+
:from_port => nil,
|
159
|
+
:to_port => nil,
|
160
|
+
:cidr_ip => nil,
|
161
|
+
:source_security_group_name => nil,
|
162
|
+
:source_security_group_owner_id => nil }.merge(options)
|
163
|
+
|
164
|
+
# lets not validate the rest of the possible permutations of required params and instead let
|
165
|
+
# EC2 sort it out on the server side. We'll only require :group_name as that is always needed.
|
166
|
+
raise ArgumentError, "No :group_name provided" if options[:group_name].nil? || options[:group_name].empty?
|
167
|
+
|
168
|
+
params = { "GroupName" => options[:group_name],
|
169
|
+
"IpProtocol" => options[:ip_protocol],
|
170
|
+
"FromPort" => options[:from_port].to_s,
|
171
|
+
"ToPort" => options[:to_port].to_s,
|
172
|
+
"CidrIp" => options[:cidr_ip],
|
173
|
+
"SourceSecurityGroupName" => options[:source_security_group_name],
|
174
|
+
"SourceSecurityGroupOwnerId" => options[:source_security_group_owner_id]
|
175
|
+
}
|
176
|
+
|
177
|
+
return response_generator(:action => "RevokeSecurityGroupIngress", :params => params)
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|