aws-sdk 1.6.4 → 1.6.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -90,7 +90,7 @@ module AWS
90
90
  options[:private_key] = response.data[:key_material]
91
91
  end
92
92
 
93
- KeyPair.new(response.key_name, options)
93
+ KeyPair.new(response.key_name, options.merge(:config => config))
94
94
 
95
95
  end
96
96
 
@@ -16,14 +16,14 @@ module AWS
16
16
 
17
17
  # Represents a security group in EC2.
18
18
  #
19
- # @attr_reader [String] description The short informal description
19
+ # @attr_reader [String] description The short informal description
20
20
  # given when the group was created.
21
21
  #
22
22
  # @attr_reader [String] name The name of the security group.
23
23
  #
24
24
  # @attr_reader [String] owner_id The security group owner's id.
25
25
  #
26
- # @attr_reader [String,nil] vpc_id If this is a VPC security group,
26
+ # @attr_reader [String,nil] vpc_id If this is a VPC security group,
27
27
  # vpc_id is the ID of the VPC this group was created in.
28
28
  # Returns false otherwise.
29
29
  #
@@ -73,10 +73,10 @@ module AWS
73
73
  ]).security_group_index.key?(id)
74
74
  end
75
75
 
76
- # Returns true if this security group is a VPC security group and
76
+ # Returns true if this security group is a VPC security group and
77
77
  # not an EC2 security group. VPC security groups belong to a VPC
78
78
  # subnet and can have egress rules.
79
- # @return [Boolean] Returns true if this is a VPC security group and
79
+ # @return [Boolean] Returns true if this is a VPC security group and
80
80
  # false if this is an EC2 security group.
81
81
  def vpc?
82
82
  vpc_id ? true : false
@@ -92,7 +92,7 @@ module AWS
92
92
 
93
93
  # @return [SecurityGroup::IngressIpPermissionCollection] Returns a
94
94
  # collection of {IpPermission} objects that represents all of
95
- # the (ingress) permissions this security group has
95
+ # the (ingress) permissions this security group has
96
96
  # authorizations for.
97
97
  def ingress_ip_permissions
98
98
  IngressIpPermissionCollection.new(self, :config => config)
@@ -106,7 +106,7 @@ module AWS
106
106
  EgressIpPermissionCollection.new(self, :config => config)
107
107
  end
108
108
 
109
- # Adds ingress rules for ICMP pings. Defaults to 0.0.0.0/0 for
109
+ # Adds ingress rules for ICMP pings. Defaults to 0.0.0.0/0 for
110
110
  # the list of allowed IP ranges the ping can come from.
111
111
  #
112
112
  # security_group.allow_ping # anyone can ping servers in this group
@@ -124,13 +124,13 @@ module AWS
124
124
  authorize_ingress('icmp', -1, *sources)
125
125
  end
126
126
 
127
- # Removes ingress rules for ICMP pings. Defaults to 0.0.0.0/0 for
127
+ # Removes ingress rules for ICMP pings. Defaults to 0.0.0.0/0 for
128
128
  # the list of IP ranges to revoke.
129
129
  #
130
130
  # @param [String] sources One or more IP ranges to disallow ping from.
131
131
  # Defaults to 0.0.0.0/0
132
132
  #
133
- # @return [nil]
133
+ # @return [nil]
134
134
  #
135
135
  def disallow_ping *sources
136
136
  sources << '0.0.0.0/0' if sources.empty?
@@ -141,7 +141,7 @@ module AWS
141
141
  # Ingress rules permit inbound traffic over a given protocol for
142
142
  # a given port range from one or more souce ip addresses.
143
143
  #
144
- # This example grants the whole internet (0.0.0.0/0) access to port 80
144
+ # This example grants the whole internet (0.0.0.0/0) access to port 80
145
145
  # over TCP (HTTP web traffic).
146
146
  #
147
147
  # security_group.authorize_ingress(:tcp, 80)
@@ -152,19 +152,19 @@ module AWS
152
152
  # security_group.authorize_ingress(:tcp, 20..21)
153
153
  #
154
154
  # == Sources
155
- #
155
+ #
156
156
  # Security groups accept ingress trafic from:
157
157
  #
158
158
  # * CIDR IP addresses
159
159
  # * security groups
160
160
  # * load balancers
161
- #
161
+ #
162
162
  # === Ip Addresses
163
163
  #
164
- # In the following example allow incoming SSH from a list of
164
+ # In the following example allow incoming SSH from a list of
165
165
  # IP address ranges.
166
166
  #
167
- # security_group.authorize_ingress(:tcp, 22,
167
+ # security_group.authorize_ingress(:tcp, 22,
168
168
  # '111.111.111.111/0', '222.222.222.222/0')
169
169
  #
170
170
  # === Security Groups
@@ -194,13 +194,13 @@ module AWS
194
194
  # You can do the same with a hash as well (with either +:group_id+
195
195
  # or +:group_name+):
196
196
  #
197
- # sg.authorize_ingress(:tcp, 21..22, { :group_id => 'sg-id', :user_id => 'abcxyz123' })
197
+ # sg.authorize_ingress(:tcp, 21..22, { :group_id => 'sg-id', :user_id => 'abcxyz123' })
198
198
  #
199
199
  # === Load Balancers
200
200
  #
201
201
  # If you use ELB to manage load balancers, then you need to add
202
202
  # ingress permissions to the security groups they route traffic into.
203
- # You can do this by passing the {ELB::LoadBalancer} into
203
+ # You can do this by passing the {ELB::LoadBalancer} into
204
204
  # authorize_ingress:
205
205
  #
206
206
  # load_balancer = AWS::ELB.new.load_balancers['web-load-balancer']
@@ -218,14 +218,14 @@ module AWS
218
218
  # or the string equivalent.
219
219
  #
220
220
  # @param [Integer, Range] ports The port (or port range) to allow
221
- # traffic through. You can pass a single integer (like 80)
221
+ # traffic through. You can pass a single integer (like 80)
222
222
  # or a range (like 20..21).
223
223
  #
224
224
  # @param [Mixed] sources One or more CIDR IP addresses,
225
225
  # security groups, or load balancers. Security groups
226
226
  # can be specified as hashes.
227
227
  #
228
- # A security group hash must provide either +:group_id+ or
228
+ # A security group hash must provide either +:group_id+ or
229
229
  # +:group_name+ for the security group. If the security group
230
230
  # does not belong to you aws account then you must also
231
231
  # provide +:user_id+ (which can be an AWS account ID or alias).
@@ -240,7 +240,7 @@ module AWS
240
240
  nil
241
241
  end
242
242
 
243
- # Revokes an ingress (inbound) ip permission. This is the inverse
243
+ # Revokes an ingress (inbound) ip permission. This is the inverse
244
244
  # operation to {#authorize_ingress}. See {#authorize_ingress}
245
245
  # for param and option documentation.
246
246
  #
@@ -257,14 +257,14 @@ module AWS
257
257
  end
258
258
 
259
259
  # Authorize egress (outbound) traffic for a VPC security group.
260
- #
260
+ #
261
261
  # # allow traffic for all protocols/ports from the given sources
262
262
  # security_group.authorize_egress('10.0.0.0/16', '10.0.0.1/16')
263
263
  #
264
264
  # # allow tcp traffic outband via port 80
265
265
  # security_group.authorize_egress('10.0.0.0/16',
266
266
  # :protocol => :tcp, :ports => 80..80)
267
- #
267
+ #
268
268
  # @note Calling this method on a non-VPC security group raises an error.
269
269
  #
270
270
  # @overload authorize_egress(*sources, options = {})
@@ -281,7 +281,7 @@ module AWS
281
281
  #
282
282
  # @option options [Range<Integer>,Integer] :ports (nil) An optional
283
283
  # port or range of ports. This option is required depending on
284
- # the protocol.
284
+ # the protocol.
285
285
  #
286
286
  # @return [nil]
287
287
  #
@@ -292,7 +292,7 @@ module AWS
292
292
  nil
293
293
  end
294
294
 
295
- # Revokes an egress (outound) ip permission. This is the inverse
295
+ # Revokes an egress (outound) ip permission. This is the inverse
296
296
  # operation to {#authorize_egress}. See {#authorize_egress}
297
297
  # for param and option documentation.
298
298
  #
@@ -307,13 +307,13 @@ module AWS
307
307
  nil
308
308
  end
309
309
 
310
- # Deletes this security group.
310
+ # Deletes this security group.
311
311
  #
312
- # If you attempt to delete a security group that contains
312
+ # If you attempt to delete a security group that contains
313
313
  # instances, or attempt to delete a security group that is referenced
314
- # by another security group, an error is raised. For example, if
315
- # security group B has a rule that allows access from security
316
- # group A, security group A cannot be deleted until the rule is
314
+ # by another security group, an error is raised. For example, if
315
+ # security group B has a rule that allows access from security
316
+ # group A, security group A cannot be deleted until the rule is
317
317
  # removed.
318
318
  # @return [nil]
319
319
  def delete
@@ -321,6 +321,11 @@ module AWS
321
321
  nil
322
322
  end
323
323
 
324
+ # @private
325
+ def <=> other
326
+ self.id <=> other.id
327
+ end
328
+
324
329
  # @private
325
330
  def resource_type
326
331
  'security-group'
@@ -361,7 +366,7 @@ module AWS
361
366
  ensure_vpc do
362
367
 
363
368
  last = args.last
364
-
369
+
365
370
  if last.is_a?(Hash) and (last.key?(:protocol) or last.key?(:ports))
366
371
  # hashes at the end of egress methods could be a hash intedned
367
372
  # to be a source, like:
@@ -409,11 +414,11 @@ module AWS
409
414
  when SecurityGroup
410
415
  groups << { :group_id => source.id, :user_id => source.owner_id }
411
416
 
412
- when ELB::LoadBalancer
417
+ when ELB::LoadBalancer
413
418
  groups << source.source_security_group
414
419
 
415
420
  when Hash
416
-
421
+
417
422
  # group name or id required
418
423
  unless source.has_key?(:group_id) or source.has_key?(:group_name)
419
424
  raise ArgumentError, 'invalid ip permission hash, ' +
@@ -437,7 +442,7 @@ module AWS
437
442
  ips << { :cidr_ip => '0.0.0.0/0' } if ips.empty? and groups.empty?
438
443
 
439
444
  [ips, groups]
440
-
445
+
441
446
  end
442
447
 
443
448
  # @private
@@ -31,7 +31,7 @@ module AWS
31
31
  # grant permission to.
32
32
  #
33
33
  # @option options [Boolean] :egress (false) When true this IpPermission
34
- # is assumed to be an egree permission.
34
+ # is assumed to be an egress permission.
35
35
  #
36
36
  def initialize security_group, protocol, ports, options = {}
37
37
 
@@ -55,7 +55,7 @@ module AWS
55
55
 
56
56
  end
57
57
 
58
- # @return [SecurityGroup] The security group this permission is
58
+ # @return [SecurityGroup] The security group this permission is
59
59
  # authorized for.
60
60
  attr_reader :security_group
61
61
 
@@ -68,8 +68,8 @@ module AWS
68
68
  # @return [Array] An array of string CIDR ip addresses.
69
69
  attr_reader :ip_ranges
70
70
 
71
- # @return [Array] An array of security groups that have been
72
- # granted access with this permission.
71
+ # @return [Array] An array of security groups that have been
72
+ # granted access with this permission.
73
73
  attr_reader :groups
74
74
 
75
75
  # @return [Boolean] True if this is an egress permission
@@ -99,9 +99,9 @@ module AWS
99
99
  other.security_group == security_group and
100
100
  other.protocol == protocol and
101
101
  other.port_range == port_range and
102
- other.ip_ranges == ip_ranges and
103
- other.groups == groups and
104
- other.egress == egress?
102
+ other.ip_ranges.sort == ip_ranges.sort and
103
+ other.groups.sort == groups.sort and
104
+ other.egress? == egress?
105
105
  end
106
106
  alias_method :==, :eql?
107
107
 
@@ -18,9 +18,9 @@ module AWS
18
18
  #
19
19
  # == Creating a Backend Server Policy
20
20
  #
21
- # Creating a backend server policy can be a bit tricky. A
22
- # BackendServerAuthenticationPolicyType policy only has one
23
- # attribute, a list of public key policies.
21
+ # Creating a backend server policy can be a bit tricky. A
22
+ # BackendServerAuthenticationPolicyType policy only has one
23
+ # attribute, a list of public key policies.
24
24
  #
25
25
  # Before you can assign a policy to a backend server instance port you
26
26
  # must create on of the appropriate type:
@@ -36,7 +36,7 @@ module AWS
36
36
  # KEY
37
37
  #
38
38
  # public_key_policy = load_balancer.policies.create("pkp",
39
- # 'PublicKeyPolicyType', 'PublicKey' => public_key.strip)
39
+ # 'PublicKeyPolicyType', 'PublicKey' => public_key.strip)
40
40
  #
41
41
  # # step 2, create the backend server policy, passing the public key policy
42
42
  #
@@ -54,16 +54,16 @@ module AWS
54
54
  # can assign it to a backend instance port:
55
55
  #
56
56
  # load_balancer.backend_server_policies[80] = backend_policy
57
- #
57
+ #
58
58
  # If you want to remove the policy you can pass nil instead.
59
59
  #
60
60
  # # removes the policy from instance port 80
61
- # load_balancer.backend_server_policies[80] = nil
61
+ # load_balancer.backend_server_policies[80] = nil
62
62
  #
63
63
  # You can also get the current policy:
64
64
  #
65
65
  # load_balancer.backend_server_policies[80] # returns a policy or nil
66
- #
66
+ #
67
67
  class BackendServerPolicyCollection
68
68
 
69
69
  include Core::Collection::Simple
@@ -78,7 +78,7 @@ module AWS
78
78
 
79
79
  # Returns the policy currently assigned to the given instance port.
80
80
  #
81
- # @param [Integer] instance_port The backend server port to
81
+ # @param [Integer] instance_port The backend server port to
82
82
  # get the currently policy of.
83
83
  #
84
84
  # @return [LoadBalancerPolicy,nil] Returns the load balancer policy
@@ -125,10 +125,9 @@ module AWS
125
125
  instance_port = options[:instance_port]
126
126
 
127
127
  load_balancer.backend_server_descriptions.each do |desc|
128
- if instance_port.nil? or desc.instance_port == instance_port
129
- desc.policy_names.collect do |policy_name|
130
- policy = load_balancer.policies[policy_name]
131
- yield(policy)
128
+ if instance_port.nil? or desc[:instance_port] == instance_port
129
+ desc[:policy_names].each do |policy_name|
130
+ yield(load_balancer.policies[policy_name])
132
131
  end
133
132
  end
134
133
  end
@@ -17,8 +17,6 @@ module AWS
17
17
  # Client class for Elastic Load Balancing (ELB).
18
18
  class Client < Core::QueryClient
19
19
 
20
- define_client_methods('2012-06-01')
21
-
22
20
  # @private
23
21
  CACHEABLE_REQUESTS = Set[]
24
22
 
@@ -495,6 +493,8 @@ module AWS
495
493
 
496
494
  ## end client methods ##
497
495
 
496
+ define_client_methods('2012-06-01')
497
+
498
498
  end
499
499
  end
500
500
  end
@@ -15,7 +15,7 @@ module AWS
15
15
  class ELB
16
16
 
17
17
  class InstanceCollection
18
-
18
+
19
19
  include Core::Collection::Simple
20
20
 
21
21
  def initialize load_balancer, options = {}
@@ -57,7 +57,7 @@ module AWS
57
57
  end
58
58
 
59
59
  instance
60
-
60
+
61
61
  end
62
62
 
63
63
  # Returns an array of instance health descriptions. Each description
@@ -69,9 +69,9 @@ module AWS
69
69
  #
70
70
  # * +:state+ - Specifies the current state of the instance.
71
71
  #
72
- # * +:reason_code+ - Provides information about the cause of
73
- # OutOfService instances. Specifically, it indicates whether the
74
- # cause is Elastic Load Balancing or the instance behind the
72
+ # * +:reason_code+ - Provides information about the cause of
73
+ # OutOfService instances. Specifically, it indicates whether the
74
+ # cause is Elastic Load Balancing or the instance behind the
75
75
  # load balancer.
76
76
  #
77
77
  # You can get the health of all instances for this load balancer
@@ -93,7 +93,7 @@ module AWS
93
93
  #
94
94
  # == Health for a Single Instance
95
95
  #
96
- # If you want the health of a single instance you can use the {#[]}
96
+ # If you want the health of a single instance you can use the {#[]}
97
97
  # instead:
98
98
  #
99
99
  # load_balancer.instances['i-123456'].elb_health
@@ -125,7 +125,7 @@ module AWS
125
125
 
126
126
  end
127
127
 
128
- # @return [LoadBalancer] Returns the load balancer this collection
128
+ # @return [LoadBalancer] Returns the load balancer this collection
129
129
  # belongs to.
130
130
  attr_reader :load_balancer
131
131
 
@@ -164,8 +164,7 @@ module AWS
164
164
  protected
165
165
  def _each_item options = {}
166
166
  load_balancer.instance_descriptions.each do |instance|
167
- instance = self[instance.instance_id]
168
- yield(instance)
167
+ yield(self[instance[:instance_id]])
169
168
  end
170
169
  end
171
170
 
@@ -42,31 +42,31 @@ module AWS
42
42
  # @return [LoadBalancer]
43
43
  attr_reader :load_balancer
44
44
 
45
- # @return [Integer]
45
+ # @return [Integer]
46
46
  attr_reader :port
47
47
 
48
48
  # @return [Symbol] Returns the protocl for this listener.
49
49
  def protocol
50
- proto = @protocol || _description.listener.protocol
50
+ proto = @protocol ||= _description[:listener][:protocol]
51
51
  proto.to_s.downcase.to_sym
52
52
  end
53
53
 
54
54
  # @return [Integer]
55
55
  def instance_port
56
- @instance_port || _description.listener.instance_port
56
+ @instance_port ||= _description[:listener][:instance_port]
57
57
  end
58
58
 
59
59
  # @return [Symbol]
60
60
  def instance_protocol
61
- proto = @instance_protocol || _description.listener.instance_protocol
61
+ proto = @instance_protocol ||= _description[:listener][:instance_protocol]
62
62
  proto.to_s.downcase.to_sym
63
63
  end
64
64
 
65
- # Sets the certificate that terminates the specified listener's SSL
66
- # connections. The specified certificate replaces any prior
65
+ # Sets the certificate that terminates the specified listener's SSL
66
+ # connections. The specified certificate replaces any prior
67
67
  # certificate for this listener.
68
68
  #
69
- # @param [String,IAM::ServerCertificate] server_certificate The ARN
69
+ # @param [String,IAM::ServerCertificate] server_certificate The ARN
70
70
  # of an IAM::ServerCertificate or an IAM::ServerCertificate object.
71
71
  #
72
72
  # @return [nil]
@@ -89,9 +89,9 @@ module AWS
89
89
  # associated with this listener, or nil if there is none.
90
90
  def server_certificate
91
91
  desc = _description
92
- if desc.listener.respond_to?(:ssl_certificate_id)
92
+ if desc[:listener][:ssl_certificate_id]
93
93
  AWS.memoize do
94
- arn = desc.listener.ssl_certificate_id
94
+ arn = desc[:listener][:ssl_certificate_id]
95
95
  iam = IAM.new(:config => config)
96
96
  iam.server_certificates.find{|cert| cert.arn == arn }
97
97
  end
@@ -101,10 +101,10 @@ module AWS
101
101
  end
102
102
 
103
103
  # @return [LoadBalancerPolicy,nil] Returns the current policy for this
104
- # listener. Returns nil if no load balancer policy has been
104
+ # listener. Returns nil if no load balancer policy has been
105
105
  # associated with it.
106
106
  def policy
107
- policy_name = _description.policy_names.first
107
+ policy_name = _description[:policy_names].first
108
108
  policy_name ? load_balancer.policies[policy_name] : nil
109
109
  end
110
110
 
@@ -115,7 +115,7 @@ module AWS
115
115
 
116
116
  policy_name = policy_or_policy_name.is_a?(LoadBalancerPolicy) ?
117
117
  policy_or_policy_name.name : policy_or_policy_name.to_s
118
-
118
+
119
119
  client.set_load_balancer_policies_of_listener(
120
120
  :load_balancer_name => load_balancer.name,
121
121
  :load_balancer_port => port,
@@ -171,16 +171,17 @@ module AWS
171
171
 
172
172
  # @private
173
173
  def eql? other
174
- other.is_a?(Listener) and
174
+ other.is_a?(Listener) and
175
175
  other.load_balancer == load_balancer and
176
176
  other.port == port
177
177
  end
178
178
  alias_method :==, :eql?
179
179
 
180
180
  protected
181
+
181
182
  def _description
182
- load_balancer.listener_descriptions.find do |desc|
183
- desc.listener.load_balancer_port == port
183
+ load_balancer.listener_descriptions.find do |desc|
184
+ desc[:listener][:load_balancer_port] == port
184
185
  end
185
186
  end
186
187