aws-sdk 1.3.5 → 1.3.6

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 (57) hide show
  1. data/lib/aws/api_config/EC2-2011-12-15.yml +2791 -0
  2. data/lib/aws/core.rb +4 -4
  3. data/lib/aws/core/client.rb +1 -0
  4. data/lib/aws/core/client_logging.rb +9 -2
  5. data/lib/aws/core/lazy_error_classes.rb +1 -1
  6. data/lib/aws/core/response.rb +5 -0
  7. data/lib/aws/core/service_interface.rb +3 -2
  8. data/lib/aws/core/uri_escape.rb +1 -2
  9. data/lib/aws/ec2.rb +80 -1
  10. data/lib/aws/ec2/client.rb +29 -10
  11. data/lib/aws/ec2/client/xml.rb +51 -1
  12. data/lib/aws/ec2/customer_gateway.rb +90 -0
  13. data/lib/aws/ec2/customer_gateway_collection.rb +73 -0
  14. data/lib/aws/ec2/dhcp_options.rb +106 -0
  15. data/lib/aws/ec2/dhcp_options_collection.rb +87 -0
  16. data/lib/aws/ec2/filtered_collection.rb +27 -2
  17. data/lib/aws/ec2/image.rb +7 -4
  18. data/lib/aws/ec2/instance.rb +54 -2
  19. data/lib/aws/ec2/instance_collection.rb +5 -3
  20. data/lib/aws/ec2/internet_gateway.rb +122 -0
  21. data/lib/aws/ec2/internet_gateway/attachment.rb +78 -0
  22. data/lib/aws/ec2/internet_gateway_collection.rb +54 -0
  23. data/lib/aws/ec2/network_acl.rb +254 -0
  24. data/lib/aws/ec2/network_acl/association.rb +56 -0
  25. data/lib/aws/ec2/network_acl/entry.rb +147 -0
  26. data/lib/aws/ec2/network_acl_collection.rb +65 -0
  27. data/lib/aws/ec2/network_interface.rb +174 -0
  28. data/lib/aws/ec2/network_interface/attachment.rb +100 -0
  29. data/lib/aws/ec2/network_interface_collection.rb +103 -0
  30. data/lib/aws/ec2/region.rb +11 -1
  31. data/lib/aws/ec2/resource.rb +6 -2
  32. data/lib/aws/ec2/route_table.rb +204 -0
  33. data/lib/aws/ec2/route_table/association.rb +119 -0
  34. data/lib/aws/ec2/route_table/route.rb +113 -0
  35. data/lib/aws/ec2/route_table_collection.rb +73 -0
  36. data/lib/aws/ec2/security_group.rb +15 -5
  37. data/lib/aws/ec2/security_group_collection.rb +15 -12
  38. data/lib/aws/ec2/subnet.rb +161 -0
  39. data/lib/aws/ec2/subnet_collection.rb +115 -0
  40. data/lib/aws/ec2/vpc.rb +166 -0
  41. data/lib/aws/ec2/vpc_collection.rb +71 -0
  42. data/lib/aws/ec2/vpn_connection.rb +99 -0
  43. data/lib/aws/ec2/vpn_connection/telemetry.rb +49 -0
  44. data/lib/aws/ec2/vpn_connection_collection.rb +96 -0
  45. data/lib/aws/ec2/vpn_gateway.rb +123 -0
  46. data/lib/aws/ec2/vpn_gateway/attachment.rb +45 -0
  47. data/lib/aws/ec2/vpn_gateway_collection.rb +77 -0
  48. data/lib/aws/iam/login_profile.rb +4 -0
  49. data/lib/aws/iam/user.rb +6 -0
  50. data/lib/aws/record/hash_model.rb +3 -3
  51. data/lib/aws/simple_workflow.rb +6 -3
  52. data/lib/aws/simple_workflow/activity_task_collection.rb +7 -2
  53. data/lib/aws/simple_workflow/decision_task_collection.rb +11 -5
  54. data/lib/aws/simple_workflow/option_formatters.rb +7 -0
  55. data/lib/net/http/connection_pool.rb +19 -5
  56. metadata +33 -5
  57. data/lib/aws/api_config/EC2-2011-02-28.yml +0 -2314
@@ -0,0 +1,73 @@
1
+ # Copyright 2011-2012 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
+ module AWS
15
+ class EC2
16
+
17
+ class CustomerGatewayCollection < Collection
18
+
19
+ include TaggedCollection
20
+ include Core::Collection::Simple
21
+
22
+ # @param [Integer] bgp_asn The customer gateway's Border Gateway
23
+ # Protocol (BGP) Autonomous System Number (ASN).
24
+ #
25
+ # @param [String] ip_address The Internet-routable IP address for the
26
+ # customer gateway's outside interface. The address must be static.
27
+ #
28
+ # @param [Hash] options
29
+ #
30
+ # @option options [String] :vpn_type ('ipsec.1') The type of VPN
31
+ # connection this customer gateway supports.
32
+ #
33
+ # @return [CustomerGateway]
34
+ #
35
+ def create bgp_asn, ip_address, options = {}
36
+
37
+ client_opts = {}
38
+ client_opts[:bgp_asn] = bgp_asn
39
+ client_opts[:public_ip] = ip_address
40
+ client_opts[:type] = options[:vpn_type] || 'ipsec.1'
41
+
42
+ resp = client.create_customer_gateway(client_opts)
43
+
44
+ CustomerGateway.new_from(:create_customer_gateway,
45
+ resp.customer_gateway,
46
+ resp.customer_gateway.customer_gateway_id,
47
+ :config => config)
48
+
49
+ end
50
+
51
+ # @param [String] customer_gateway_id
52
+ # @return [CustomerGateway]
53
+ def [] customer_gateway_id
54
+ CustomerGateway.new(customer_gateway_id, :config => config)
55
+ end
56
+
57
+ protected
58
+
59
+ def _each_item options = {}, &block
60
+ response = filtered_request(:describe_customer_gateways, options, &block)
61
+ response.customer_gateway_set.each do |g|
62
+
63
+ gateway = CustomerGateway.new_from(:describe_customer_gateways, g,
64
+ g.customer_gateway_id, :config => config)
65
+
66
+ yield(gateway)
67
+
68
+ end
69
+ end
70
+
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,106 @@
1
+ # Copyright 2011-2012 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
+ module AWS
15
+ class EC2
16
+
17
+ class DHCPOptions < Resource
18
+
19
+ include TaggedItem
20
+
21
+ # @private
22
+ def initialize dhcp_options_id, options = {}
23
+ @dhcp_options_id = dhcp_options_id
24
+ super
25
+ end
26
+
27
+ # @return [String]
28
+ attr_reader :dhcp_options_id
29
+
30
+ alias_method :id, :dhcp_options_id
31
+
32
+ attribute :dhcp_configuration_set, :static => true
33
+
34
+ protected :dhcp_configuration_set
35
+
36
+ populates_from(:create_dhcp_options) do |resp|
37
+ resp.dhcp_options if resp.dhcp_options.dhcp_options_id == id
38
+ end
39
+
40
+ populates_from(:describe_dhcp_options) do |resp|
41
+ resp.dhcp_options_set.find do |dhcp_options|
42
+ dhcp_options.dhcp_options_id == dhcp_options_id
43
+ end
44
+ end
45
+
46
+ # @return [Hash]
47
+ def configuration
48
+ dhcp_configuration_set.inject({}) do |config,opt|
49
+ key = opt.key.gsub(/-/, '_').to_sym
50
+ values = opt.value_set.map(&:value)
51
+ values = values.first if key == :domain_name
52
+ values = values.first.to_i if key == :netbios_node_type
53
+ config.merge(key => values)
54
+ end
55
+ end
56
+
57
+ # Associates this set of options to the given VPC.
58
+ # @param [VPC,String] vpc A {VPC} object or a vpc id string.
59
+ # @return [nil]
60
+ def associate vpc
61
+ client_opts = {}
62
+ client_opts[:dhcp_options_id] = dhcp_options_id
63
+ client_opts[:vpc_id] = vpc_id_option(vpc)
64
+ client.associate_dhcp_options(client_opts)
65
+ nil
66
+ end
67
+
68
+ # Deletes these DHCP options. An error will be raised if these
69
+ # options are currently associated to a VPC. To disassociate this
70
+ # set of options from a VPC, associate a different set of options
71
+ # with the VPC.
72
+ #
73
+ # @return [nil]
74
+ #
75
+ def delete
76
+ client_opts = {}
77
+ client_opts[:dhcp_options_id] = dhcp_options_id
78
+ client.delete_dhcp_options(client_opts)
79
+ nil
80
+ end
81
+
82
+ # @return [VPCCollection] Returns a collection that represents
83
+ # all VPCs currently using this dhcp options.
84
+ def vpcs
85
+ vpcs = VPCCollection.new(:config => config)
86
+ vpcs.filter('dhcp-options-id', dhcp_options_id)
87
+ end
88
+
89
+ # @return [Boolean] Returns true if the dhcp options exists.
90
+ def exists?
91
+ begin
92
+ get_resource
93
+ true
94
+ rescue Errors::InvalidDhcpOptionID::NotFound
95
+ false
96
+ end
97
+ end
98
+
99
+ protected
100
+ def vpc_id_option vpc
101
+ vpc.is_a?(VPC) ? vpc.vpc_id : vpc
102
+ end
103
+
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,87 @@
1
+ # Copyright 2011-2012 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
+ module AWS
15
+ class EC2
16
+
17
+ class DHCPOptionsCollection < Collection
18
+
19
+ include TaggedCollection
20
+ include Core::Collection::Simple
21
+
22
+ # @param [Hash] options
23
+ #
24
+ # @option options [required,String] :domain_name A domain name of your
25
+ # choice (e.g., example.com).
26
+ #
27
+ # @option options [Array<String>] :domain_name_servers
28
+ # The IP addresses of domain name servers. You can specify up to
29
+ # four addresses.
30
+ #
31
+ # @option options [Array<String>] :ntp_servers
32
+ # The IP addresses of Network Time Protocol (NTP) servers. You can
33
+ # specify up to four addresses.
34
+ #
35
+ # @option options [Array<String>] :netbios_name_servers
36
+ # The IP addresses of NetBIOS name servers. You can specify up to
37
+ # four addresses.
38
+ #
39
+ # @option options [String] :netbios_node_type Value indicating the
40
+ # NetBIOS node type (1, 2, 4, or 8). For more information about the
41
+ # values, go to RFC 2132. We recommend you only use 2 at this time
42
+ # (broadcast and multicast are currently not supported).
43
+ #
44
+ def create options = {}
45
+
46
+ configurations = []
47
+ options.each_pair do |opt,values|
48
+ opt = opt.to_s.gsub(/_/, '-')
49
+ values = values.is_a?(Array) ? values : [values]
50
+ configurations << { :key => opt, :values => values.map(&:to_s) }
51
+ end
52
+
53
+ client_opts = {}
54
+ client_opts[:dhcp_configurations] = configurations
55
+
56
+ resp = client.create_dhcp_options(client_opts)
57
+
58
+ DHCPOptions.new_from(:create_dhcp_options,
59
+ resp.dhcp_options,
60
+ resp.dhcp_options.dhcp_options_id,
61
+ :config => config)
62
+
63
+ end
64
+
65
+ # @param [String] dhcp_options_id
66
+ # @return [DHCPOptions]
67
+ def [] dhcp_options_id
68
+ DHCPOptions.new(dhcp_options_id, :config => config)
69
+ end
70
+
71
+ protected
72
+
73
+ def _each_item options = {}, &block
74
+ response = filtered_request(:describe_dhcp_options, options, &block)
75
+ response.dhcp_options_set.each do |opts|
76
+
77
+ options = DHCPOptions.new_from(:describe_dhcp_options, opts,
78
+ opts.dhcp_options_id, :config => config)
79
+
80
+ yield(options)
81
+
82
+ end
83
+ end
84
+
85
+ end
86
+ end
87
+ end
@@ -47,11 +47,36 @@ module AWS
47
47
  client.send(client_method, options)
48
48
  end
49
49
 
50
+ protected
51
+ def vpc_id_option options
52
+ vpc_id = options[:vpc]
53
+ vpc_id ||= options[:vpc_id]
54
+ vpc_id ||= filter_value_for('vpc-id')
55
+ vpc_id = vpc_id.id if vpc_id.is_a?(VPC)
56
+ vpc_id
57
+ end
58
+
59
+ protected
60
+ def subnet_id_option options
61
+ subnet_id = options.delete(:subnet)
62
+ subnet_id ||= options[:subnet_id]
63
+ subnet_id ||= filter_value_for('subnet-id')
64
+ subnet_id = subnet_id.id if subnet_id.is_a?(Subnet)
65
+ subnet_id
66
+ end
67
+
68
+ protected
69
+ def filter_value_for filter_name
70
+ @filters.each do |filter|
71
+ return filter[:values].first if filter[:name] == filter_name
72
+ end
73
+ nil
74
+ end
75
+
50
76
  # @private
51
77
  protected
52
78
  def preserved_options
53
- { :config => config,
54
- :filters => @filters }
79
+ { :config => config, :filters => @filters }
55
80
  end
56
81
 
57
82
  # @private
@@ -128,6 +128,7 @@ module AWS
128
128
  attribute :hypervisor, :to_sym => true, :static => true
129
129
 
130
130
  attribute :block_device_mapping
131
+
131
132
  protected :block_device_mapping
132
133
 
133
134
  attribute :product_codes, :static => true do
@@ -231,12 +232,14 @@ module AWS
231
232
  # image.add_product_codes ['ABCXYZ', 'MNOPQR']
232
233
  #
233
234
  # @param [Array<String>] product_codes
235
+ #
234
236
  # @return [nil]
237
+ #
235
238
  def add_product_codes *product_codes
236
- opts = {}
237
- opts[:image_id] = self.id
238
- opts[:product_codes] = product_codes.flatten
239
- client.modify_image_attribute(opts)
239
+ client_opts = {}
240
+ client_opts[:image_id] = self.id
241
+ client_opts[:product_codes] = product_codes.flatten
242
+ client.modify_image_attribute(client_opts)
240
243
  nil
241
244
  end
242
245
 
@@ -274,11 +274,16 @@ module AWS
274
274
 
275
275
  mutable_describe_call_attribute :ramdisk_id, :set_as => :ramdisk
276
276
 
277
- mutable_describe_call_attribute :source_dest_check?,
278
- :as => :source_dest_check
277
+ mutable_describe_attribute :source_dest_check do
278
+ translates_output{|bool| bool == "true" }
279
+ end
280
+
281
+ alias_method :source_dest_check?, :source_dest_check
279
282
 
280
283
  mutable_describe_call_attribute :group_set
281
284
 
285
+ describe_call_attribute :network_interface_set
286
+
282
287
  mutable_describe_attribute(:user_data) do
283
288
  translates_output {|v| Base64.decode64(v) if v }
284
289
  translates_input {|v| Base64.encode64(v).strip }
@@ -351,6 +356,53 @@ module AWS
351
356
  provider.provides :monitoring
352
357
  end
353
358
 
359
+ # @return [VPC,nil] Returns the VPC this instance was launched in.
360
+ # If this instance was not launched inside a VPC, nil is returned.
361
+ def vpc
362
+ if vpc_id
363
+ VPC.new(vpc_id, :config => config)
364
+ end
365
+ end
366
+
367
+ # @return [Subnet,nil] Returns the VPC subnet this instance was
368
+ # launched in. Returns nil if this was not launched in a VPC.
369
+ def subnet
370
+ if subnet_id
371
+ Subnet.new(subnet_id, :vpc_id => vpc_id, :config => config)
372
+ end
373
+ end
374
+
375
+ # @return [Array<NetworkInterface>] Returns a list of elastic network
376
+ # interfaces attached to this instance (VPC only). Non-vpc
377
+ # instance may not have attached network interfaces.
378
+ def network_interfaces
379
+ network_interface_set.collect do |ni|
380
+ NetworkInterface.new_from(:describe_network_interfaces, ni,
381
+ ni.network_interface_id, :config => config)
382
+ end
383
+ end
384
+
385
+ # Attaches a network interface to this instance (VPC only).
386
+ #
387
+ # @param [NetworkInterface,String] network_interface A network interface
388
+ # (or network interface id string) to attach to this vpc instance.
389
+ #
390
+ # @param [Hash] options
391
+ #
392
+ # @option (see NetworkInterface#attach)
393
+ #
394
+ # @return [nil]
395
+ #
396
+ def attach_network_interface network_interface, options = {}
397
+ if network_interface.is_a?(NetworkInterface)
398
+ network_interface.attach(self, options)
399
+ else
400
+ i = NetworkInterface.new(network_interface, :config => config)
401
+ i.attach(self, options)
402
+ end
403
+ nil
404
+ end
405
+
354
406
  # @return [Array<SecurityGroup>] Returns a list of security
355
407
  # groups the instance belongs to.
356
408
  def security_groups
@@ -169,8 +169,8 @@ module AWS
169
169
  # Determines whether the instance stops or terminates on
170
170
  # instance-initiated shutdown.
171
171
  #
172
- # @option options [String] :subnet (nil) The ID of an EC2 VPC
173
- # subnet to launch the instance in.
172
+ # @option options [Subnet,String] :subnet (nil) The VPC Subnet (or
173
+ # subnet id string) to launch the instance in.
174
174
  #
175
175
  # @option options [String] :private_ip_address (nil) If you're using VPC,
176
176
  # you can optionally use this option to assign the instance a
@@ -236,7 +236,9 @@ module AWS
236
236
 
237
237
  options[:placement] = placement unless placement.empty?
238
238
 
239
- options[:subnet_id] = options.delete(:subnet) if options[:subnet]
239
+ if subnet_id = subnet_id_option(options)
240
+ options[:subnet_id] = subnet_id
241
+ end
240
242
 
241
243
  security_group_opts(options)
242
244
 
@@ -0,0 +1,122 @@
1
+ # Copyright 2011-2012 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
+ require 'aws/ec2/internet_gateway/attachment'
15
+
16
+ module AWS
17
+ class EC2
18
+
19
+ class InternetGateway < Resource
20
+
21
+ include TaggedItem
22
+
23
+ def initialize internet_gateway_id, options = {}
24
+ @internet_gateway_id = internet_gateway_id
25
+ super
26
+ end
27
+
28
+ # @return [String]
29
+ attr_reader :internet_gateway_id
30
+
31
+ alias_method :id, :internet_gateway_id
32
+
33
+ attribute :vpc_id
34
+
35
+ attribute :attachment_set
36
+
37
+ protected :attachment_set
38
+
39
+ populates_from(:describe_internet_gateways) do |resp|
40
+ resp.internet_gateway_set.find do |gateway|
41
+ gateway.internet_gateway_id == internet_gateway_id
42
+ end
43
+ end
44
+
45
+ # @return [Array<InternetGateway::Attachment>]
46
+ def attachments
47
+ attachment_set.map {|details| Attachment.new(self, details) }
48
+ end
49
+
50
+ # @return [VPC,nil] Returns the currently attached VPC, or nil
51
+ # if this gateway has not been attached.
52
+ def vpc
53
+ if attachment = attachments.first
54
+ attachment.vpc
55
+ end
56
+ end
57
+
58
+ # Attaches this internet gateway to the given VPC. If this
59
+ # gateway is already attached to a different VPC, it will
60
+ # be detached from that one first. If you pass nil, then
61
+ # this internet gateway will
62
+ #
63
+ # internet_gateway.vpc = 'vpc-123'
64
+ #
65
+ # @param [VPC,String] vpc A {VPC} object or a vpc id string.
66
+ #
67
+ def vpc= vpc
68
+ if attachment = attachments.first
69
+ attachment.delete
70
+ end
71
+ attach(vpc) if vpc
72
+ end
73
+
74
+ # Attaches this internet gateway to the given VPC.
75
+ # @param [VPC,String] vpc A {VPC} object or a vpc id string.
76
+ # @return [nil]
77
+ def attach vpc
78
+ client_opts = {}
79
+ client_opts[:internet_gateway_id] = internet_gateway_id
80
+ client_opts[:vpc_id] = vpc_id_option(vpc)
81
+ client.attach_internet_gateway(client_opts)
82
+ nil
83
+ end
84
+
85
+ # Detaches this internet gateway from the given VPC.
86
+ # @param [VPC,String] vpc A {VPC} object or a vpc id string.
87
+ # @return [nil]
88
+ def detach vpc
89
+ client_opts = {}
90
+ client_opts[:internet_gateway_id] = internet_gateway_id
91
+ client_opts[:vpc_id] = vpc_id_option(vpc)
92
+ client.detach_internet_gateway(client_opts)
93
+ nil
94
+ end
95
+
96
+ # Deletes this internet gateway.
97
+ # @return [nil]
98
+ def delete
99
+ client_opts = {}
100
+ client_opts[:internet_gateway_id] = internet_gateway_id
101
+ client.delete_internet_gateway(client_opts)
102
+ nil
103
+ end
104
+
105
+ # @return [Boolean] Returns true if the gateway exists.
106
+ def exists?
107
+ begin
108
+ get_resource
109
+ true
110
+ rescue Errors::InvalidInternetGatewayID::NotFound
111
+ false
112
+ end
113
+ end
114
+
115
+ protected
116
+ def vpc_id_option vpc
117
+ vpc.is_a?(VPC) ? vpc.vpc_id : vpc
118
+ end
119
+
120
+ end
121
+ end
122
+ end