aws-sdk 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
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 RouteTableCollection < Collection
18
+
19
+ include TaggedCollection
20
+ include Core::Collection::Simple
21
+
22
+ # Creates a route table.
23
+ #
24
+ # @param [Hash] options
25
+ #
26
+ # @option options [VPC,String] :vpc The vpc or vpc id of where you want
27
+ # to create the route table. This option is required if this
28
+ # collection does not have a populated vpc ({#vpc} returns nil).
29
+ #
30
+ # @return [RouteTable]
31
+ #
32
+ def create options = {}
33
+
34
+ client_opts = {}
35
+ client_opts[:vpc_id] = vpc_id_option(options)
36
+
37
+ resp = client.create_route_table(client_opts)
38
+
39
+ RouteTable.new_from(:create_route_table, resp.route_table,
40
+ resp.route_table.route_table_id, :config => config)
41
+
42
+ end
43
+
44
+ # @param [String] route_table_id
45
+ # @return [RouteTable]
46
+ def [] route_table_id
47
+ RouteTable.new(route_table_id, :config => config)
48
+ end
49
+
50
+ # @return [RouteTable] Returns the main (default) route table.
51
+ # This route table is automatically assigned to new subnets
52
+ # and can not be deleted.
53
+ def main_route_table
54
+ @main = AWS.memoize { self.find {|rt| rt.main? } } if @main.nil?
55
+ @main
56
+ end
57
+
58
+ protected
59
+ def _each_item options = {}, &block
60
+ response = filtered_request(:describe_route_tables, options, &block)
61
+ response.route_table_set.each do |t|
62
+
63
+ route_table = RouteTable.new_from(:describe_route_tables, t,
64
+ t.route_table_id, :config => config)
65
+
66
+ yield(route_table)
67
+
68
+ end
69
+ end
70
+
71
+ end
72
+ end
73
+ end
@@ -38,15 +38,17 @@ module AWS
38
38
 
39
39
  include TaggedItem
40
40
 
41
- def initialize id, options = {}
42
- @id = id
41
+ def initialize security_group_id, options = {}
42
+ @security_group_id = security_group_id
43
43
  super
44
44
  end
45
45
 
46
- # @return [String] The ID of the security group.
47
- attr_reader :id
46
+ # @return [String]
47
+ attr_reader :security_group_id
48
48
 
49
- alias_method :group_id, :id
49
+ alias_method :group_id, :security_group_id
50
+
51
+ alias_method :id, :security_group_id
50
52
 
51
53
  attribute :name, :as => :group_name, :static => true
52
54
 
@@ -80,6 +82,14 @@ module AWS
80
82
  vpc_id ? true : false
81
83
  end
82
84
 
85
+ # @return [VPC,nil] Returns the VPC this security group belongs to,
86
+ # or nil if this is not a VPC security group.
87
+ def vpc
88
+ if vpc_id
89
+ VPC.new(vpc_id, :config => config)
90
+ end
91
+ end
92
+
83
93
  # @return [SecurityGroup::IngressIpPermissionCollection] Returns a
84
94
  # collection of {IpPermission} objects that represents all of
85
95
  # the (ingress) permissions this security group has
@@ -26,11 +26,13 @@ module AWS
26
26
  # of this security group. Accepts alphanumeric characters, spaces,
27
27
  # dashes, and underscores. If left blank the description will be set
28
28
  # to the name.
29
- # @option options [String] :vpc_id (nil) The ID of a VPC to create
30
- # a security group in. If this option is left blank then an
31
- # EC2 security group is created. If this option is provided a VPC
32
- # security group will be created.
29
+ #
30
+ # @option options [VPC,String] :vpc (nil) A VPC or VPC id string to
31
+ # create the security group in. When specified a VPC security
32
+ # group is created.
33
+ #
33
34
  # @return [SecurityGroup]
35
+ #
34
36
  def create name, options = {}
35
37
 
36
38
  description = options[:description] || name
@@ -38,14 +40,20 @@ module AWS
38
40
  create_opts = {}
39
41
  create_opts[:group_name] = name
40
42
  create_opts[:description] = description
41
- create_opts[:vpc_id] = options[:vpc_id] if options[:vpc_id]
43
+
44
+ vpc_id = options[:vpc]
45
+ vpc_id ||= options[:vpc_id] # for backwards compatability
46
+ vpc_id ||= filter_value_for('vpc-id')
47
+ vpc_id = vpc_id.id if vpc_id.is_a?(VPC)
48
+
49
+ create_opts[:vpc_id] = vpc_id if vpc_id
42
50
 
43
51
  response = client.create_security_group(create_opts)
44
52
 
45
53
  SecurityGroup.new(response.group_id, {
46
54
  :name => name,
47
55
  :description => description,
48
- :vpc_id => options[:vpc_id],
56
+ :vpc_id => create_opts[:vpc_id],
49
57
  :config => config })
50
58
 
51
59
  end
@@ -53,7 +61,7 @@ module AWS
53
61
  # @param [String] group_id The group id of a security group.
54
62
  # @return [SecurityGroup] The group with the given id.
55
63
  def [] group_id
56
- super
64
+ SecurityGroup.new(group_id, :config => config)
57
65
  end
58
66
 
59
67
  # Specify one or more criteria to filter security groups by.
@@ -122,11 +130,6 @@ module AWS
122
130
  nil
123
131
  end
124
132
 
125
- protected
126
- def member_class
127
- SecurityGroup
128
- end
129
-
130
133
  end
131
134
  end
132
135
  end
@@ -0,0 +1,161 @@
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
+ # @attr_reader [String] vpc_id
18
+ #
19
+ # @attr_reader [Symbol] state
20
+ #
21
+ # @attr_reader [String] cidr_block
22
+ #
23
+ # @attr_reader [Integer] available_ip_address_count
24
+ #
25
+ # @attr_reader [String] availability_zone_name
26
+ #
27
+ class Subnet < Resource
28
+
29
+ include TaggedItem
30
+
31
+ def initialize subnet_id, options = {}
32
+ @subnet_id = subnet_id
33
+ super
34
+ end
35
+
36
+ # @return [String]
37
+ attr_reader :subnet_id
38
+
39
+ alias_method :id, :subnet_id
40
+
41
+ attribute :vpc_id, :static => true
42
+
43
+ attribute :state, :to_sym => true
44
+
45
+ attribute :cidr_block, :static => true
46
+
47
+ attribute :available_ip_address_count, :integer => true, :static => true
48
+
49
+ attribute :availability_zone_name,
50
+ :as => :availability_zone, :static => true
51
+
52
+ populates_from(:create_subnet) do |resp|
53
+ resp.subnet if resp.subnet.subnet_id == subnet_id
54
+ end
55
+
56
+ populates_from(:describe_subnets) do |resp|
57
+ resp.subnet_set.find{|s| s.subnet_id == subnet_id }
58
+ end
59
+
60
+ # @return [VPC] Returns the VPC this subnet belongs to.
61
+ def vpc
62
+ VPC.new(vpc_id, :config => config)
63
+ end
64
+
65
+ # @return [NetworkACL] Returns the network ACL currently assigned
66
+ # to this subnet.
67
+ def network_acl
68
+ network_acl_association.network_acl
69
+ end
70
+
71
+ # Replaces the currently assigned network ACL with the passed one.
72
+ # @param [NetworkACL,String] network_acl A {NetworkACL} or network
73
+ # ACL id to assign to this subnet.
74
+ def network_acl= network_acl
75
+ network_acl_association.replace_network_acl(network_acl)
76
+ end
77
+
78
+ # @return [NetworkACL::Association] Returns the association between
79
+ # this subnet and its network ACL.
80
+ def network_acl_association
81
+ associations = AWS.memoize { vpc.network_acls.map(&:associations) }.flatten
82
+ associations.first{|a| a.subnet == self }
83
+ end
84
+
85
+ # @return [RouteTable] Returns the route table currently associated
86
+ # with this subnet.
87
+ def route_table
88
+ route_table_association.route_table
89
+ end
90
+
91
+ # Sets the route table for this subnet. If there is already a
92
+ # route table associated with this subnet, that association
93
+ # is replaced.
94
+ #
95
+ # @param [RouteTable,String] route_Table A {RouteTable} object or
96
+ # a route table id string.
97
+ #
98
+ # @return [RouteTable::Association]
99
+ #
100
+ def set_route_table route_table
101
+
102
+ unless route_table.is_a?(RouteTable)
103
+ route_table = RouteTable.new(route_table, :config => config)
104
+ end
105
+
106
+ client_opts = {}
107
+ client_opts[:route_table_id] = route_table.id
108
+
109
+ assoc = route_table_association
110
+
111
+ if assoc.main?
112
+ client_opts[:subnet_id] = subnet_id
113
+ response = client.associate_route_table(client_opts)
114
+ association_id = response.association_id
115
+ else
116
+ client_opts[:association_id] = assoc.association_id
117
+ resp = client.replace_route_table_association(client_opts)
118
+ association_id = resp.new_association_id
119
+ end
120
+
121
+ RouteTable::Association.new(route_table, association_id, subnet_id)
122
+
123
+ end
124
+ alias_method :route_table=, :set_route_table
125
+
126
+ # @return [RouteTable::Association] Returns the association between
127
+ # this subnet and its route table.
128
+ def route_table_association
129
+ assocs = AWS.memoize { vpc.route_tables.map(&:associations) }.flatten
130
+ assocs.find{|a| a.subnet == self } || assocs.find{|a| a.main? }
131
+ end
132
+
133
+ # See also {#availability_zone_name}.
134
+ # @return [AvailabilityZone]
135
+ def availability_zone
136
+ AvailabilityZone.new(availability_zone_name, :config => config)
137
+ end
138
+
139
+ # @return [InstanceCollection] Returns a filtered collection of
140
+ # instances launched in this subnet.
141
+ def instances
142
+ InstanceCollection.new(:config => config).filter('subnet-id', id)
143
+ end
144
+
145
+ # @return [NetworkInterfaceCollection] Returns a collection that
146
+ # represents all of the network interfaces for this subnet.
147
+ def network_interfaces
148
+ NetworkInterfaceCollection.new(:config => config).filter('subnet-id', id)
149
+ end
150
+
151
+ # Deletes the current subnet. The subnet must be empty before it can
152
+ # be deleted.
153
+ # @return [nil]
154
+ def delete
155
+ client.delete_subnet(:subnet_id => subnet_id)
156
+ nil
157
+ end
158
+
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,115 @@
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
+ # Represents a collection of VPC subnets. You can get a subnet collection
18
+ # two ways. You can get a collection that represents ALL subnets (across
19
+ # all your VPCs). You can also get a subnet collection that represents
20
+ # subnets within a single vpc.
21
+ #
22
+ # # represents all subnets
23
+ # subnets = ec2.subnets
24
+ #
25
+ # # represents subnets within the named vpc
26
+ # subnets = ec2.vpcs['vpc-12345'].subnets
27
+ #
28
+ # == Creating a Subnet
29
+ #
30
+ # To create a subnet, call {#create} on a subnet collection, passing in
31
+ # a suitable CIDR block.
32
+ #
33
+ # subnet = subnets.create('10.0.0.0/20')
34
+ #
35
+ # You can optionally pass the availability zone you want the subnet
36
+ # created in.
37
+ #
38
+ # == Getting a Subnet
39
+ #
40
+ # If you know the subnet id, you can get a subnet using {#[]}.
41
+ #
42
+ # subnet = subnets['subnet-id-here']
43
+ #
44
+ # You can filter subnets as well. See the EC2 API documentation
45
+ # (http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html) for a complete list of accepted filters.
46
+ #
47
+ # subnet = subnets.filter('state', 'available').first
48
+ #
49
+ class SubnetCollection < Collection
50
+
51
+ include TaggedCollection
52
+ include Core::Collection::Simple
53
+
54
+ # Creates a Subnet. Subnets require a valid CIDR block and
55
+ # are created inside a VPC. If this collection does not
56
+ # have a
57
+ #
58
+ # @param [String] cidr_block The CIDR block you want the subnet to
59
+ # cover (e.g., 10.0.0.0/24).
60
+ #
61
+ # @param [Hash] options
62
+ #
63
+ # @option options [VPC,String] :vpc The VPC (or VPC id string) to
64
+ # create the subnet in.
65
+ #
66
+ # @option options [String,AvailabilityZone] :availability_zone
67
+ # The Availability Zone you want the subnet in.
68
+ # AWS selects a default zone for you (recommended).
69
+ #
70
+ # @return [Subnet]
71
+ #
72
+ def create cidr_block, options = {}
73
+
74
+ client_opts = {}
75
+ client_opts[:vpc_id] = vpc_id_option(options)
76
+ client_opts[:cidr_block] = cidr_block
77
+ client_opts[:availability_zone] = az_option(options) if
78
+ options[:availability_zone]
79
+
80
+ resp = client.create_subnet(client_opts)
81
+
82
+ Subnet.new_from(:create_subnet, resp.subnet,
83
+ resp.subnet.subnet_id, :config => config)
84
+
85
+ end
86
+
87
+ # @param [String] subnet_id
88
+ # @return [Subnet] Returns a subnet with the given id.
89
+ def [] subnet_id
90
+ Subnet.new(subnet_id, :config => config)
91
+ end
92
+
93
+ protected
94
+ def az_option options
95
+ options[:availability_zone].is_a?(AvailabilityZone) ?
96
+ options[:availability_zone].name :
97
+ options[:availability_zone]
98
+ end
99
+
100
+ protected
101
+ def _each_item options = {}, &block
102
+ response = filtered_request(:describe_subnets, options, &block)
103
+ response.subnet_set.each do |s|
104
+
105
+ subnet = Subnet.new_from(:describe_subnets,
106
+ s, s.subnet_id, :config => config)
107
+
108
+ yield(subnet)
109
+
110
+ end
111
+ end
112
+
113
+ end
114
+ end
115
+ end