aws-sdk 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. data/ca-bundle.crt +2 -348
  2. data/lib/aws.rb +24 -49
  3. data/lib/aws/{common.rb → core.rb} +120 -9
  4. data/lib/aws/{api_config.rb → core/api_config.rb} +19 -20
  5. data/lib/aws/core/api_config_transform.rb +36 -0
  6. data/lib/aws/core/async_handle.rb +91 -0
  7. data/lib/aws/core/authorize_v2.rb +39 -0
  8. data/lib/aws/{authorize_v3.rb → core/authorize_v3.rb} +16 -15
  9. data/lib/aws/{api_config_transform.rb → core/authorize_with_session_token.rb} +9 -12
  10. data/lib/aws/core/autoloader.rb +64 -0
  11. data/lib/aws/core/cacheable.rb +78 -0
  12. data/lib/aws/core/client.rb +471 -0
  13. data/lib/aws/core/client_logging.rb +125 -0
  14. data/lib/aws/core/collections.rb +229 -0
  15. data/lib/aws/core/configuration.rb +358 -0
  16. data/lib/aws/core/configured_client_methods.rb +76 -0
  17. data/lib/aws/core/configured_grammars.rb +63 -0
  18. data/lib/aws/{configured_option_grammars.rb → core/configured_option_grammars.rb} +18 -20
  19. data/lib/aws/{configured_xml_grammars.rb → core/configured_xml_grammars.rb} +19 -21
  20. data/lib/aws/core/default_signer.rb +67 -0
  21. data/lib/aws/core/http/curb_handler.rb +129 -0
  22. data/lib/aws/core/http/handler.rb +77 -0
  23. data/lib/aws/core/http/httparty_handler.rb +113 -0
  24. data/lib/aws/core/http/net_http_handler.rb +124 -0
  25. data/lib/aws/core/http/request.rb +207 -0
  26. data/lib/aws/core/http/response.rb +73 -0
  27. data/lib/aws/{ignore_result_element.rb → core/ignore_result_element.rb} +14 -18
  28. data/lib/aws/core/indifferent_hash.rb +88 -0
  29. data/lib/aws/core/inflection.rb +47 -0
  30. data/lib/aws/core/lazy_error_classes.rb +62 -0
  31. data/lib/aws/{uri_escape.rb → core/meta_utils.rb} +24 -23
  32. data/lib/aws/core/model.rb +57 -0
  33. data/lib/aws/{authorize_with_session_token.rb → core/naming.rb} +9 -8
  34. data/lib/aws/core/option_grammar.rb +562 -0
  35. data/lib/aws/core/policy.rb +914 -0
  36. data/lib/aws/core/resource.rb +380 -0
  37. data/lib/aws/core/resource_cache.rb +40 -0
  38. data/lib/aws/core/response.rb +125 -0
  39. data/lib/aws/core/response_cache.rb +50 -0
  40. data/lib/aws/core/service_interface.rb +60 -0
  41. data/lib/aws/core/uri_escape.rb +46 -0
  42. data/lib/aws/core/xml_grammar.rb +926 -0
  43. data/lib/aws/ec2.rb +47 -16
  44. data/lib/aws/ec2/attachment.rb +0 -2
  45. data/lib/aws/ec2/attachment_collection.rb +1 -6
  46. data/lib/aws/ec2/availability_zone.rb +0 -2
  47. data/lib/aws/ec2/availability_zone_collection.rb +0 -3
  48. data/lib/aws/ec2/client.rb +6 -9
  49. data/lib/aws/ec2/client/xml.rb +3 -6
  50. data/lib/aws/ec2/collection.rb +1 -4
  51. data/lib/aws/ec2/config.rb +18 -0
  52. data/lib/aws/ec2/elastic_ip.rb +0 -2
  53. data/lib/aws/ec2/elastic_ip_collection.rb +0 -4
  54. data/lib/aws/ec2/errors.rb +1 -4
  55. data/lib/aws/ec2/has_permissions.rb +0 -2
  56. data/lib/aws/ec2/image.rb +0 -5
  57. data/lib/aws/ec2/image_collection.rb +0 -6
  58. data/lib/aws/ec2/instance.rb +23 -9
  59. data/lib/aws/ec2/instance_collection.rb +85 -22
  60. data/lib/aws/ec2/key_pair.rb +0 -2
  61. data/lib/aws/ec2/key_pair_collection.rb +1 -4
  62. data/lib/aws/ec2/permission_collection.rb +2 -5
  63. data/lib/aws/ec2/region.rb +0 -2
  64. data/lib/aws/ec2/region_collection.rb +0 -4
  65. data/lib/aws/ec2/request.rb +4 -9
  66. data/lib/aws/ec2/reserved_instances.rb +0 -3
  67. data/lib/aws/ec2/reserved_instances_collection.rb +0 -4
  68. data/lib/aws/ec2/reserved_instances_offering.rb +0 -3
  69. data/lib/aws/ec2/reserved_instances_offering_collection.rb +0 -4
  70. data/lib/aws/ec2/resource.rb +3 -5
  71. data/lib/aws/ec2/resource_tag_collection.rb +1 -6
  72. data/lib/aws/ec2/security_group.rb +204 -72
  73. data/lib/aws/ec2/security_group/egress_ip_permission_collection.rb +53 -0
  74. data/lib/aws/ec2/security_group/ip_permission.rb +92 -10
  75. data/lib/aws/ec2/security_group/ip_permission_collection.rb +14 -15
  76. data/lib/aws/ec2/security_group_collection.rb +11 -8
  77. data/lib/aws/ec2/snapshot.rb +0 -4
  78. data/lib/aws/ec2/snapshot_collection.rb +0 -4
  79. data/lib/aws/ec2/tag.rb +0 -3
  80. data/lib/aws/ec2/tag_collection.rb +1 -8
  81. data/lib/aws/ec2/tagged_item.rb +1 -3
  82. data/lib/aws/ec2/volume.rb +0 -6
  83. data/lib/aws/ec2/volume_collection.rb +0 -4
  84. data/lib/aws/errors.rb +0 -3
  85. data/lib/aws/iam.rb +33 -12
  86. data/lib/aws/iam/access_key.rb +0 -3
  87. data/lib/aws/iam/access_key_collection.rb +0 -3
  88. data/lib/aws/iam/account_alias_collection.rb +0 -2
  89. data/lib/aws/iam/client.rb +6 -8
  90. data/lib/aws/iam/client/xml.rb +4 -8
  91. data/lib/aws/iam/collection.rb +2 -5
  92. data/lib/aws/iam/config.rb +18 -0
  93. data/lib/aws/iam/errors.rb +2 -4
  94. data/lib/aws/iam/group.rb +0 -5
  95. data/lib/aws/iam/group_collection.rb +0 -3
  96. data/lib/aws/iam/group_policy_collection.rb +0 -2
  97. data/lib/aws/iam/group_user_collection.rb +1 -4
  98. data/lib/aws/iam/login_profile.rb +0 -2
  99. data/lib/aws/iam/mfa_device.rb +1 -3
  100. data/lib/aws/iam/mfa_device_collection.rb +0 -3
  101. data/lib/aws/iam/policy.rb +2 -4
  102. data/lib/aws/iam/policy_collection.rb +0 -3
  103. data/lib/aws/iam/request.rb +3 -7
  104. data/lib/aws/iam/resource.rb +1 -4
  105. data/lib/aws/iam/server_certificate.rb +0 -2
  106. data/lib/aws/iam/server_certificate_collection.rb +0 -3
  107. data/lib/aws/iam/signing_certificate.rb +0 -2
  108. data/lib/aws/iam/signing_certificate_collection.rb +0 -3
  109. data/lib/aws/iam/user.rb +0 -7
  110. data/lib/aws/iam/user_collection.rb +0 -3
  111. data/lib/aws/iam/user_group_collection.rb +0 -3
  112. data/lib/aws/iam/user_policy.rb +0 -2
  113. data/lib/aws/iam/user_policy_collection.rb +0 -3
  114. data/lib/aws/rails.rb +5 -4
  115. data/lib/aws/record.rb +4 -1
  116. data/lib/aws/record/base.rb +3 -2
  117. data/lib/aws/record/errors.rb +1 -3
  118. data/lib/aws/s3.rb +31 -6
  119. data/lib/aws/s3/access_control_list.rb +0 -2
  120. data/lib/aws/s3/acl_object.rb +10 -12
  121. data/lib/aws/s3/bucket.rb +1 -9
  122. data/lib/aws/s3/bucket_collection.rb +2 -5
  123. data/lib/aws/s3/bucket_version_collection.rb +1 -5
  124. data/lib/aws/s3/client.rb +34 -37
  125. data/lib/aws/s3/client/xml.rb +11 -14
  126. data/lib/aws/{resource_cache.rb → s3/config.rb} +6 -20
  127. data/lib/aws/s3/errors.rb +6 -7
  128. data/lib/aws/s3/multipart_upload.rb +1 -4
  129. data/lib/aws/s3/multipart_upload_collection.rb +1 -6
  130. data/lib/aws/s3/object_collection.rb +1 -5
  131. data/lib/aws/s3/object_metadata.rb +1 -3
  132. data/lib/aws/s3/object_upload_collection.rb +1 -7
  133. data/lib/aws/s3/object_version.rb +1 -4
  134. data/lib/aws/s3/object_version_collection.rb +1 -4
  135. data/lib/aws/s3/policy.rb +3 -5
  136. data/lib/aws/s3/prefix_and_delimiter_collection.rb +0 -2
  137. data/lib/aws/s3/prefixed_collection.rb +0 -2
  138. data/lib/aws/s3/presigned_post.rb +1 -3
  139. data/lib/aws/s3/request.rb +2 -5
  140. data/lib/aws/s3/s3_object.rb +1 -8
  141. data/lib/aws/s3/tree.rb +8 -6
  142. data/lib/aws/s3/tree/branch_node.rb +0 -3
  143. data/lib/aws/s3/tree/child_collection.rb +1 -5
  144. data/lib/aws/s3/tree/leaf_node.rb +0 -5
  145. data/lib/aws/s3/tree/parent.rb +1 -4
  146. data/lib/aws/s3/uploaded_part.rb +1 -3
  147. data/lib/aws/s3/uploaded_part_collection.rb +1 -5
  148. data/lib/aws/simple_db.rb +21 -6
  149. data/lib/aws/simple_db/attribute.rb +1 -6
  150. data/lib/aws/simple_db/attribute_collection.rb +1 -7
  151. data/lib/aws/simple_db/client.rb +7 -9
  152. data/lib/aws/simple_db/client/options.rb +2 -4
  153. data/lib/aws/simple_db/client/xml.rb +5 -10
  154. data/lib/aws/{naming.rb → simple_db/config.rb} +3 -14
  155. data/lib/aws/simple_db/delete_attributes.rb +0 -2
  156. data/lib/aws/simple_db/domain.rb +1 -6
  157. data/lib/aws/simple_db/domain_collection.rb +1 -4
  158. data/lib/aws/simple_db/domain_metadata.rb +1 -3
  159. data/lib/aws/simple_db/errors.rb +1 -4
  160. data/lib/aws/simple_db/item.rb +1 -7
  161. data/lib/aws/simple_db/item_collection.rb +22 -23
  162. data/lib/aws/simple_db/put_attributes.rb +0 -2
  163. data/lib/aws/simple_db/request.rb +3 -7
  164. data/lib/aws/simple_email_service.rb +11 -6
  165. data/lib/aws/simple_email_service/client.rb +7 -9
  166. data/lib/aws/simple_email_service/client/options.rb +3 -6
  167. data/lib/aws/simple_email_service/client/xml.rb +4 -8
  168. data/lib/aws/simple_email_service/config.rb +19 -0
  169. data/lib/aws/simple_email_service/email_address_collection.rb +1 -3
  170. data/lib/aws/simple_email_service/errors.rb +1 -4
  171. data/lib/aws/simple_email_service/quotas.rb +1 -3
  172. data/lib/aws/simple_email_service/request.rb +3 -7
  173. data/lib/aws/sns.rb +15 -8
  174. data/lib/aws/sns/client.rb +7 -8
  175. data/lib/aws/sns/client/options.rb +3 -6
  176. data/lib/aws/sns/client/xml.rb +4 -8
  177. data/lib/aws/sns/config.rb +18 -0
  178. data/lib/aws/sns/errors.rb +1 -4
  179. data/lib/aws/sns/policy.rb +3 -5
  180. data/lib/aws/sns/request.rb +4 -9
  181. data/lib/aws/sns/subscription.rb +1 -5
  182. data/lib/aws/sns/subscription_collection.rb +1 -5
  183. data/lib/aws/sns/topic.rb +1 -6
  184. data/lib/aws/sns/topic_collection.rb +1 -4
  185. data/lib/aws/sns/topic_subscription_collection.rb +1 -4
  186. data/lib/aws/sqs.rb +14 -5
  187. data/lib/aws/sqs/client.rb +6 -9
  188. data/lib/aws/sqs/client/xml.rb +4 -7
  189. data/lib/aws/sqs/config.rb +18 -0
  190. data/lib/aws/sqs/errors.rb +1 -4
  191. data/lib/aws/sqs/policy.rb +3 -5
  192. data/lib/aws/sqs/queue.rb +2 -7
  193. data/lib/aws/sqs/queue_collection.rb +4 -5
  194. data/lib/aws/sqs/received_message.rb +1 -3
  195. data/lib/aws/sqs/received_sns_message.rb +2 -2
  196. data/lib/aws/sqs/request.rb +4 -7
  197. data/lib/aws/sts.rb +12 -6
  198. data/lib/aws/sts/client.rb +6 -8
  199. data/lib/aws/sts/client/xml.rb +4 -8
  200. data/lib/aws/sts/config.rb +18 -0
  201. data/lib/aws/sts/errors.rb +1 -4
  202. data/lib/aws/sts/federated_session.rb +0 -2
  203. data/lib/aws/sts/policy.rb +3 -5
  204. data/lib/aws/sts/request.rb +3 -7
  205. metadata +60 -50
  206. data/lib/aws/async_handle.rb +0 -90
  207. data/lib/aws/authorize_v2.rb +0 -37
  208. data/lib/aws/base_client.rb +0 -488
  209. data/lib/aws/cacheable.rb +0 -79
  210. data/lib/aws/client_logging.rb +0 -122
  211. data/lib/aws/collections.rb +0 -230
  212. data/lib/aws/configuration.rb +0 -357
  213. data/lib/aws/configured_client_methods.rb +0 -81
  214. data/lib/aws/configured_grammars.rb +0 -65
  215. data/lib/aws/default_signer.rb +0 -65
  216. data/lib/aws/http/curb_handler.rb +0 -127
  217. data/lib/aws/http/handler.rb +0 -77
  218. data/lib/aws/http/httparty_handler.rb +0 -103
  219. data/lib/aws/http/request.rb +0 -165
  220. data/lib/aws/http/request_param.rb +0 -64
  221. data/lib/aws/http/response.rb +0 -72
  222. data/lib/aws/indifferent_hash.rb +0 -86
  223. data/lib/aws/inflection.rb +0 -46
  224. data/lib/aws/lazy_error_classes.rb +0 -64
  225. data/lib/aws/meta_utils.rb +0 -43
  226. data/lib/aws/model.rb +0 -57
  227. data/lib/aws/option_grammar.rb +0 -565
  228. data/lib/aws/policy.rb +0 -914
  229. data/lib/aws/resource.rb +0 -381
  230. data/lib/aws/response.rb +0 -125
  231. data/lib/aws/response_cache.rb +0 -50
  232. data/lib/aws/service_interface.rb +0 -60
  233. data/lib/aws/xml_grammar.rb +0 -925
@@ -11,21 +11,8 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/common'
15
- require 'aws/service_interface'
16
- require 'aws/ec2/client'
17
- require 'aws/ec2/instance_collection'
18
- require 'aws/ec2/security_group_collection'
19
- require 'aws/ec2/elastic_ip_collection'
20
- require 'aws/ec2/key_pair_collection'
21
- require 'aws/ec2/tag_collection'
22
- require 'aws/ec2/region_collection'
23
- require 'aws/ec2/availability_zone_collection'
24
- require 'aws/ec2/image_collection'
25
- require 'aws/ec2/volume_collection'
26
- require 'aws/ec2/snapshot_collection'
27
- require 'aws/ec2/reserved_instances_collection'
28
- require 'aws/ec2/reserved_instances_offering_collection'
14
+ require 'aws/core'
15
+ require 'aws/ec2/config'
29
16
 
30
17
  module AWS
31
18
 
@@ -244,7 +231,51 @@ module AWS
244
231
  #
245
232
  class EC2
246
233
 
247
- include ServiceInterface
234
+ AWS.register_autoloads(self) do
235
+ autoload :Attachment, 'attachment'
236
+ autoload :AttachmentCollection, 'attachment_collection'
237
+ autoload :AvailabilityZone, 'availability_zone'
238
+ autoload :AvailabilityZoneCollection, 'availability_zone_collection'
239
+ autoload :BlockDeviceMappings, 'block_device_mappings'
240
+ autoload :Client, 'client'
241
+ autoload :Collection, 'collection'
242
+ autoload :ConfigTransform, 'config_transform'
243
+ autoload :ElasticIp, 'elastic_ip'
244
+ autoload :ElasticIpCollection, 'elastic_ip_collection'
245
+ autoload :Errors, 'errors'
246
+ autoload :FilteredCollection, 'filtered_collection'
247
+ autoload :HasPermissions, 'has_permissions'
248
+ autoload :Image, 'image'
249
+ autoload :ImageCollection, 'image_collection'
250
+ autoload :Instance, 'instance'
251
+ autoload :InstanceCollection, 'instance_collection'
252
+ autoload :KeyPair, 'key_pair'
253
+ autoload :KeyPairCollection, 'key_pair_collection'
254
+ autoload :PermissionCollection, 'permission_collection'
255
+ autoload :Region, 'region'
256
+ autoload :RegionCollection, 'region_collection'
257
+ autoload :Request, 'request'
258
+ autoload :ReservedInstances, 'reserved_instances'
259
+ autoload :ReservedInstancesCollection, 'reserved_instances_collection'
260
+ autoload :ReservedInstancesOffering, 'reserved_instances_offering'
261
+ autoload :ReservedInstancesOfferingCollection,
262
+ 'reserved_instances_offering_collection'
263
+ autoload :Resource, 'resource'
264
+ autoload :ResourceObject, 'tag_collection'
265
+ autoload :ResourceTagCollection, 'resource_tag_collection'
266
+ autoload :SecurityGroup, 'security_group'
267
+ autoload :SecurityGroupCollection, 'security_group_collection'
268
+ autoload :Snapshot, 'snapshot'
269
+ autoload :SnapshotCollection, 'snapshot_collection'
270
+ autoload :Tag, 'tag'
271
+ autoload :TagCollection, 'tag_collection'
272
+ autoload :TaggedCollection, 'tagged_collection'
273
+ autoload :TaggedItem, 'tagged_item'
274
+ autoload :Volume, 'volume'
275
+ autoload :VolumeCollection, 'volume_collection'
276
+ end
277
+
278
+ include Core::ServiceInterface
248
279
 
249
280
  # @return [InstanceCollection] A collection representing all instances
250
281
  def instances
@@ -11,8 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/resource'
15
-
16
14
  module AWS
17
15
  class EC2
18
16
 
@@ -11,11 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/model'
15
- require 'aws/ec2/volume'
16
- require 'aws/ec2/instance'
17
- require 'aws/ec2/attachment'
18
-
19
14
  module AWS
20
15
  class EC2
21
16
 
@@ -25,7 +20,7 @@ module AWS
25
20
  # @see Volume
26
21
  class AttachmentCollection
27
22
 
28
- include Model
23
+ include Core::Model
29
24
  include Enumerable
30
25
 
31
26
  attr_reader :volume
@@ -11,8 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/ec2/resource'
15
-
16
14
  module AWS
17
15
  class EC2
18
16
 
@@ -11,9 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/ec2/collection'
15
- require 'aws/ec2/availability_zone'
16
-
17
14
  module AWS
18
15
  class EC2
19
16
 
@@ -11,20 +11,17 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/base_client'
15
- require 'aws/configured_client_methods'
16
- require 'aws/ec2/request'
17
- require 'aws/ec2/client/xml'
18
- require 'aws/ec2/errors'
19
- require 'aws/inflection'
20
-
21
14
  module AWS
22
15
  class EC2
23
16
 
24
17
  # @private
25
- class Client < BaseClient
18
+ class Client < Core::Client
19
+
20
+ AWS.register_autoloads(self) do
21
+ autoload :XML, 'xml'
22
+ end
26
23
 
27
- include ConfiguredClientMethods
24
+ include Core::ConfiguredClientMethods
28
25
 
29
26
  API_VERSION = '2011-02-28'
30
27
 
@@ -11,17 +11,14 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/base_client'
15
- require 'aws/configured_xml_grammars'
16
-
17
14
  module AWS
18
15
  class EC2
19
- class Client < BaseClient
16
+ class Client < Core::Client
20
17
  module XML
21
18
 
22
- include ConfiguredXmlGrammars
19
+ include Core::ConfiguredXmlGrammars
23
20
 
24
- BaseError = XmlGrammar.customize do
21
+ BaseError = Core::XmlGrammar.customize do
25
22
  element "Errors" do
26
23
  ignore
27
24
  element("Error") { ignore }
@@ -11,16 +11,13 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/model'
15
- require 'aws/ec2/filtered_collection'
16
-
17
14
  module AWS
18
15
  class EC2
19
16
 
20
17
  # @private
21
18
  class Collection
22
19
 
23
- include Model
20
+ include Core::Model
24
21
  include Enumerable
25
22
  include FilteredCollection
26
23
 
@@ -0,0 +1,18 @@
1
+ # Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+
14
+ AWS::Core::Configuration.module_eval do
15
+
16
+ add_service 'EC2', 'ec2', 'ec2.amazonaws.com'
17
+
18
+ end
@@ -11,8 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/ec2/resource'
15
-
16
14
  module AWS
17
15
  class EC2
18
16
 
@@ -11,10 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/model'
15
- require 'aws/ec2/collection'
16
- require 'aws/ec2/elastic_ip'
17
-
18
14
  module AWS
19
15
  class EC2
20
16
  class ElasticIpCollection < Collection
@@ -11,9 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/lazy_error_classes'
15
- require 'aws/ec2/client/xml'
16
-
17
14
  module AWS
18
15
  class EC2
19
16
 
@@ -22,7 +19,7 @@ module AWS
22
19
 
23
20
  BASE_ERROR_GRAMMAR = Client::XML::BaseError
24
21
 
25
- include LazyErrorClasses
22
+ include Core::LazyErrorClasses
26
23
 
27
24
  end
28
25
  end
@@ -11,8 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/ec2/permission_collection'
15
-
16
14
  module AWS
17
15
  class EC2
18
16
 
@@ -11,11 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/ec2/resource'
15
- require 'aws/ec2/tagged_item'
16
- require 'aws/ec2/has_permissions'
17
- require 'aws/ec2/instance_collection'
18
-
19
14
  module AWS
20
15
  class EC2
21
16
 
@@ -11,12 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/model'
15
- require 'aws/ec2/collection'
16
- require 'aws/ec2/tagged_collection'
17
- require 'aws/ec2/image'
18
- require 'aws/ec2/block_device_mappings'
19
-
20
14
  module AWS
21
15
  class EC2
22
16
 
@@ -11,14 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/inflection'
15
- require 'aws/ec2/tagged_item'
16
- require 'aws/model'
17
- require 'aws/cacheable'
18
- require 'aws/ec2/resource'
19
- require 'aws/ec2/key_pair'
20
- require 'aws/ec2/image'
21
-
22
14
  module AWS
23
15
  class EC2
24
16
 
@@ -146,6 +138,12 @@ module AWS
146
138
  # @attr_reader [String] client_token Idempotency token you
147
139
  # provided when you launched the instance.
148
140
  #
141
+ # @attr_reader [String,nil] vpc_id Instances launched in a VPC have
142
+ # a vpc_id. Normal EC2 instances return nil.
143
+ #
144
+ # @attr_reader [String,nil] subnet_id Instances launched in a VPC have
145
+ # a subnet_id. Normal EC2 instances return nil.
146
+ #
149
147
  class Instance < Resource
150
148
 
151
149
  include TaggedItem
@@ -234,6 +232,7 @@ module AWS
234
232
  describe_call_attribute :root_device_name, :static => true
235
233
 
236
234
  describe_call_attribute :block_device_mapping
235
+
237
236
  protected :block_device_mapping
238
237
 
239
238
  describe_call_attribute :instance_lifecycle, :to_sym => true
@@ -256,6 +255,10 @@ module AWS
256
255
 
257
256
  describe_call_attribute :key_name, :static => true
258
257
 
258
+ describe_call_attribute :vpc_id, :static => true
259
+
260
+ describe_call_attribute :subnet_id, :static => true
261
+
259
262
  attribute :status do
260
263
  translates_output{|state| state.name.tr("-","_").to_sym }
261
264
  end
@@ -315,7 +318,7 @@ module AWS
315
318
  # them is returned per :describe_instance_attribute call.
316
319
  mutable_describe_attributes.values.each do |attr|
317
320
 
318
- attr_opt_name = Inflection.class_name(attr.get_as.to_s)
321
+ attr_opt_name = Core::Inflection.class_name(attr.get_as.to_s)
319
322
  attr_opt_name = attr_opt_name[0,1].downcase + attr_opt_name[1..-1]
320
323
 
321
324
  provider(:describe_instance_attribute) do |provider|
@@ -410,6 +413,17 @@ module AWS
410
413
  end
411
414
  end
412
415
 
416
+ # @return [Boolean] Returns true if the instance has dedicated tenancy.
417
+ # This will be false for all non-VPC instances. Dedicated Tenancy
418
+ # comes at extra cost.
419
+ def dedicated_tenancy?
420
+ if p = placement
421
+ p.tenancy == 'dedicated'
422
+ else
423
+ false
424
+ end
425
+ end
426
+
413
427
  # @return [Image] The AMI used to launch the instance.
414
428
  def image
415
429
  Image.new(image_id, :config => config)
@@ -11,11 +11,6 @@
11
11
  # ANY KIND, either express or implied. See the License for the specific
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
- require 'aws/model'
15
- require 'aws/ec2/tagged_collection'
16
- require 'aws/ec2/collection'
17
- require 'aws/ec2/instance'
18
- require 'aws/ec2/block_device_mappings'
19
14
  require 'base64'
20
15
  require 'uuidtools'
21
16
 
@@ -72,6 +67,12 @@ module AWS
72
67
  # }
73
68
  # })
74
69
  #
70
+ # @example Launching in an Amazon VPC subnet
71
+ #
72
+ # ec2.instances.create(
73
+ # :image_id => "ami-8c1fece5",
74
+ # :subnet => "subnet-abc123ef")
75
+ #
75
76
  # @param [Hash] options Options for new instance. +:image_id+ is
76
77
  # the only required option.
77
78
  #
@@ -123,10 +124,15 @@ module AWS
123
124
  # use. Note: Launching public images without a key pair ID
124
125
  # will leave them inaccessible.
125
126
  #
126
- # @option options [Array] :security_groups The names of the
127
- # security groups that will be used to determine network
128
- # access rules for the instances. You may pass instances of
129
- # {SecurityGroup} as well.
127
+ # @option options [Array] :security_groups Security groups are used
128
+ # to determine network access rules for the instances.
129
+ # +:security_groups+ can be a single value or an array of values.
130
+ # Values should be group name strings or {SecurityGroup} objects.
131
+ #
132
+ # @option options [Array<String>] :security_group_ids Security groups
133
+ # are used to determine network access rules for the instances.
134
+ # +:security_group_ids+ accepts a single ID or an array of security
135
+ # group IDs.
130
136
  #
131
137
  # @option options [String] :user_data Arbitrary user data. You
132
138
  # do not need to encode this value.
@@ -163,6 +169,22 @@ module AWS
163
169
  # Determines whether the instance stops or terminates on
164
170
  # instance-initiated shutdown.
165
171
  #
172
+ # @option options [String] :subnet (nil) The ID of an EC2 VPC
173
+ # subnet to launch the instance in.
174
+ #
175
+ # @option options [String] :private_ip_address (nil) If you're using VPC,
176
+ # you can optionally use this option to assign the instance a
177
+ # specific available IP address from the subnet (e.g., '10.0.0.25').
178
+ # This option is not valid for instances launched outside a VPC (i.e.
179
+ # those launched without the :subnet option).
180
+ #
181
+ # @option options [Boolean] :dedicated_tenancy (false) Instances
182
+ # with dedicated tenancy will not share physical hardware with
183
+ # instances outside their VPC. *NOTE:* Dedicated tenancy
184
+ # incurs an additional service charge. This option is not
185
+ # valid for instances launched outside a VPC (e.g. those
186
+ # launched without the :subnet option).
187
+ #
166
188
  # @return [Instance or Array] If a single instance is being created,
167
189
  # this returns an {EC2::Instance} to represent the newly
168
190
  # created instance. Otherwise it returns an array of instance
@@ -200,13 +222,23 @@ module AWS
200
222
  options[:monitoring_enabled]
201
223
  options.delete(:monitoring_enabled)
202
224
 
203
- options[:placement] = {
204
- :availability_zone => options[:availability_zone].to_s
205
- } if options[:availability_zone]
206
- options.delete(:availability_zone)
225
+ placement = {}
207
226
 
208
- options[:security_groups] = group_opts(options[:security_groups]) if
209
- options[:security_groups]
227
+ if options[:availability_zone]
228
+ placement[:availability_zone] = options[:availability_zone].to_s
229
+ options.delete(:availability_zone)
230
+ end
231
+
232
+ if options[:dedicated_tenancy]
233
+ placement[:tenancy] = 'dedicated'
234
+ options.delete(:dedicated_tenancy)
235
+ end
236
+
237
+ options[:placement] = placement unless placement.empty?
238
+
239
+ options[:subnet_id] = options.delete(:subnet) if options[:subnet]
240
+
241
+ security_group_opts(options)
210
242
 
211
243
  options[:client_token] = UUIDTools::UUID.timestamp_create.to_s
212
244
 
@@ -263,19 +295,50 @@ module AWS
263
295
 
264
296
  # @private
265
297
  private
266
- def group_opts(groups)
267
- [groups].flatten.map do |g|
298
+ def security_group_opts options
299
+
300
+ ids = []
301
+ names = []
302
+
303
+ Array(options.delete(:security_group_ids)).each do |g|
304
+ ids << g
305
+ end
306
+
307
+ # this may be security group objects or names
308
+ Array(options.delete(:security_groups)).each do |g|
268
309
  case g
269
- when SecurityGroup then g.name
270
- when String then g
310
+ when String then names << g
311
+ when SecurityGroup then ids << g.id
271
312
  else
272
- raise ArgumentError.new("members of security_groups must be "+
273
- "strings or SecurityGroup objects")
313
+ raise ArgumentError, ':security_groups may only contain ' +
314
+ 'security group names, ids or objects'
274
315
  end
275
316
  end
317
+
318
+ return if ids.empty? and names.empty?
319
+
320
+ if options[:subnet_id]
321
+
322
+ # vpc instances only accepts security group ids, so any group
323
+ # names must be converted to ids, which requires a service
324
+ # request
325
+ unless names.empty?
326
+ ec2 = EC2.new(:config => config)
327
+ groups = ec2.security_groups.filter('group-name', names)
328
+ ids += groups.collect{|g| g.id }
329
+ end
330
+ options[:security_group_ids] = ids
331
+
332
+ else
333
+
334
+ # non-vpc instances accept both group names and ids, so
335
+ # we accept whichever
336
+ options[:security_groups] = names unless names.empty?
337
+ options[:security_group_ids] = ids unless ids.empty?
338
+
339
+ end
276
340
  end
277
341
 
278
342
  end
279
-
280
343
  end
281
344
  end