aws-sdk 1.3.9 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/lib/aws.rb +2 -0
  2. data/lib/aws/api_config/CloudFormation-2010-05-15.yml +204 -0
  3. data/lib/aws/api_config/EC2-2011-12-15.yml +0 -2
  4. data/lib/aws/auto_scaling.rb +1 -1
  5. data/lib/aws/auto_scaling/group.rb +1 -1
  6. data/lib/aws/auto_scaling/instance.rb +4 -4
  7. data/lib/aws/auto_scaling/notification_configuration_collection.rb +2 -2
  8. data/lib/aws/cloud_formation.rb +287 -0
  9. data/lib/aws/cloud_formation/client.rb +33 -0
  10. data/lib/aws/cloud_formation/client/xml.rb +32 -0
  11. data/lib/aws/cloud_formation/config.rb +18 -0
  12. data/lib/aws/cloud_formation/errors.rb +26 -0
  13. data/lib/aws/cloud_formation/request.rb +30 -0
  14. data/lib/aws/cloud_formation/stack.rb +255 -0
  15. data/lib/aws/cloud_formation/stack_collection.rb +206 -0
  16. data/lib/aws/cloud_formation/stack_event.rb +75 -0
  17. data/lib/aws/cloud_formation/stack_event_collection.rb +47 -0
  18. data/lib/aws/cloud_formation/stack_options.rb +72 -0
  19. data/lib/aws/cloud_formation/stack_output.rb +53 -0
  20. data/lib/aws/cloud_formation/stack_resource.rb +117 -0
  21. data/lib/aws/cloud_formation/stack_resource_collection.rb +84 -0
  22. data/lib/aws/cloud_formation/stack_resource_summary_collection.rb +72 -0
  23. data/lib/aws/cloud_formation/stack_summary.rb +71 -0
  24. data/lib/aws/cloud_formation/stack_summary_collection.rb +127 -0
  25. data/lib/aws/core.rb +5 -1
  26. data/lib/aws/core/configuration.rb +4 -1
  27. data/lib/aws/core/resource.rb +16 -0
  28. data/lib/aws/core/response.rb +7 -5
  29. data/lib/aws/ec2/elastic_ip.rb +53 -4
  30. data/lib/aws/ec2/elastic_ip_collection.rb +20 -7
  31. data/lib/aws/ec2/instance.rb +28 -7
  32. data/lib/aws/simple_email_service.rb +4 -6
  33. data/lib/aws/sts/request.rb +7 -1
  34. metadata +23 -5
@@ -0,0 +1,72 @@
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 CloudFormation
16
+
17
+ # = Stack Resource Summaries
18
+ #
19
+ # Stack summaries contain information about CloudFormation
20
+ # stack resources. You can enumerate these from a stack.
21
+ #
22
+ # stack = cfm.stacks['stack-name']
23
+ # stack.resource_summaries.each do |summary|
24
+ # puts "#{summary[:physical_resource_id]}: #{summary[:resource_status]}"
25
+ # end
26
+ #
27
+ # Each summary yielded is a hash with the following keys:
28
+ #
29
+ # * +:logical_resource_id+
30
+ # * +:physical_resource_id+
31
+ # * +:resource_type+
32
+ # * +:resource_status+
33
+ # * +:resource_status_reason+
34
+ # * +:last_updated_timestamp+
35
+ #
36
+ class StackResourceSummaryCollection
37
+
38
+ include Core::Collection::Simple
39
+
40
+ # @param [Stack] stack
41
+ # @param [Hash[ options
42
+ def initialize stack, options = {}
43
+ @stack = stack
44
+ super
45
+ end
46
+
47
+ # @return [Stack]
48
+ attr_reader :stack
49
+
50
+ protected
51
+
52
+ def _each_item options = {}
53
+ next_token = nil
54
+ begin
55
+
56
+ options = {}
57
+ options[:next_token] = next_token if next_token
58
+ options[:stack_name] = stack.name
59
+ resp = client.list_stack_resources(options)
60
+
61
+ resp.stack_resource_summaries.each do |summary|
62
+ yield(summary.to_hash)
63
+ end
64
+
65
+ next_token = resp.next_token if resp.respond_to?(:next_token)
66
+
67
+ end while next_token
68
+ end
69
+
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,71 @@
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 CloudFormation
16
+
17
+ # A stack summary contains some information about a stack. You
18
+ # can get summary information on any stack (including stacks
19
+ # deleted within the last 90 days).
20
+ #
21
+ # To get summary information, enumerate the summaries on an
22
+ # AWS::CloudFormation object:
23
+ #
24
+ # cf = AWS::CloudFormation.new
25
+ # cf.stack_summaries.each do |summary|
26
+ # puts "#{summary.stack_name} : #{summary.stack_status}"
27
+ # end
28
+ #
29
+ # You can get the full {Stack} object from a summary by calling
30
+ # {#stack}.
31
+ #
32
+ class StackSummary
33
+
34
+ # @private
35
+ def initialize stack, details
36
+ @stack = stack
37
+ details.each_pair do |attr_name,attr_value|
38
+ instance_variable_set("@#{attr_name}", attr_value)
39
+ end
40
+ end
41
+
42
+ # @return [Stack]
43
+ attr_reader :stack
44
+
45
+ # @return [Time]
46
+ attr_reader :creation_time
47
+
48
+ # @return [Time,nil]
49
+ attr_reader :last_updated_time
50
+
51
+ # @return [String]
52
+ attr_reader :stack_name
53
+
54
+ # @return [String]
55
+ attr_reader :stack_id
56
+
57
+ # @return [String]
58
+ attr_reader :stack_status
59
+
60
+ # @return [String]
61
+ attr_reader :stack_status_reason
62
+
63
+ # @return [Time,nil]
64
+ attr_reader :deletion_time
65
+
66
+ # @return [Strin]
67
+ attr_reader :template_description
68
+
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,127 @@
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 CloudFormation
16
+
17
+ # = Stack Summaries
18
+ #
19
+ # Stack summaries contain information about CloudFormation
20
+ # stacks. You can filter the stacks you want summary information
21
+ # for by one or more statuses. You can even get information
22
+ # about deleted stacks for up to 90 days.
23
+ #
24
+ # == Enumerating Stack Summaries
25
+ #
26
+ # You can enumerate all available summaries using enumerable
27
+ # methods. Yielded summaries are simple hashes.
28
+ #
29
+ # cfm = AWS::CloudFormation.new
30
+ # cfm.stack_summaries.each do |summary|
31
+ # puts summary.to_yaml
32
+ # end
33
+ #
34
+ # == Filtering Stack Summaries
35
+ #
36
+ # You can optionally provide one or more stack stasus values
37
+ # to filter the results by. Only stacks with the given status(es)
38
+ # will be enumerated.
39
+ #
40
+ # cfm.stack_summaries.with_status(:create_failed).each do |summary|
41
+ # # ...
42
+ # end
43
+ #
44
+ # # enumerate stacks with various delete statuses
45
+ # statuses = %w(delete_in_progress delete_failed delete_complete)
46
+ # cf.stack_summaries.with_status(statuses).each do |summary|
47
+ # # ...
48
+ # end
49
+ #
50
+ class StackSummaryCollection
51
+
52
+ include Core::Collection::Simple
53
+
54
+ # @private
55
+ def initialize options = {}
56
+ @filters = options[:filters]
57
+ super
58
+ end
59
+
60
+ # Limits the stacks summaries that are enumerated.
61
+ #
62
+ # cfm.stack_summaries.with_status(:create_complete).each do |summary|
63
+ # puts summary[:stack_name]
64
+ # end
65
+ #
66
+ # You can provide multiple statuses:
67
+ #
68
+ # statuses = [:create_failed, :rollback_failed]
69
+ # cfm.stack_summaries.with_status(statuses).each do |summary|
70
+ # puts summary[:stack_name]
71
+ # end
72
+ #
73
+ # Status names may be symbolized (snake-cased) or upper-cased strings
74
+ # (e.g. :create_in_progress, 'CREATE_IN_PROGRESS').
75
+ #
76
+ # @param [Symbol,String] status_filters One or more statuses to filter
77
+ # stacks with. Valid values include:
78
+ # * +:create_in_progress+
79
+ # * +:create_failed+
80
+ # * +:create_complete+
81
+ # * +:rollback_in_progress+
82
+ # * +:rollback_failed+
83
+ # * +:rollback_complete+
84
+ # * +:delete_in_progress+
85
+ # * +:delete_failed+
86
+ # * +:delete_complete+
87
+ # * +:update_in_progress+
88
+ # * +:update_complete_cleanup_in_progress+
89
+ # * +:update_complete+
90
+ # * +:update_rollback_in_progress+
91
+ # * +:update_rollback_failed+
92
+ # * +:update_rollback_complete_cleanup_in_progress+
93
+ # * +:update_rollback_complete+
94
+ #
95
+ # @return [StackSummaryCollection] Returns a new stack summary
96
+ # collection that restricts what stack summariess will be
97
+ # enumerated.
98
+ #
99
+ def with_status *status_filters
100
+ StackSummaryCollection.new(
101
+ :filters => status_filters.flatten.map(&:to_s).map(&:upcase),
102
+ :config => config)
103
+ end
104
+
105
+ protected
106
+
107
+ def _each_item options = {}
108
+ next_token = nil
109
+ begin
110
+
111
+ client_opts = {}
112
+ client_opts[:next_token] = next_token if next_token
113
+ client_opts[:stack_status_filter] = @filters if @filters
114
+ resp = client.list_stacks(client_opts)
115
+
116
+ resp.stack_summaries.each do |summary|
117
+ yield(summary.to_hash)
118
+ end
119
+
120
+ next_token = resp.next_token if resp.respond_to?(:next_token)
121
+
122
+ end while next_token
123
+ end
124
+
125
+ end
126
+ end
127
+ end
@@ -21,6 +21,7 @@ require 'aws/core/autoloader'
21
21
  # The currently supported services are:
22
22
  #
23
23
  # * {AWS::AutoScaling}
24
+ # * {AWS::CloudFormation}
24
25
  # * {AWS::DynamoDB}
25
26
  # * {AWS::EC2}
26
27
  # * {AWS::ELB}
@@ -60,7 +61,7 @@ require 'aws/core/autoloader'
60
61
  module AWS
61
62
 
62
63
  # Current version of the AWS SDK for Ruby
63
- VERSION = "1.3.9"
64
+ VERSION = "1.4.0"
64
65
 
65
66
  register_autoloads(self) do
66
67
  autoload :Errors, 'errors'
@@ -171,6 +172,9 @@ module AWS
171
172
  # @option options [String] :auto_scaling_endpoint ('autoscaling.us-east-1.amazonaws.com')
172
173
  # The service endpoint for Auto Scaling.
173
174
  #
175
+ # @option options [String] :cloud_formation_endpoint ('cloudformation.us-east-1.amazonaws.com')
176
+ # The service endpoint for AWS CloudFormation.
177
+ #
174
178
  # @option options [String] :dynamo_db_endpoint ('dynamodb.amazonaws.com')
175
179
  # The service endpoint for Amazon DynamoDB.
176
180
  #
@@ -66,6 +66,9 @@ module AWS
66
66
  # @attr_reader [String] auto_scaling_endpoint ('autoscaling.us-east-1.amazonaws.com')
67
67
  # The service endpoint for Auto Scaling.
68
68
  #
69
+ # @attr_reader [String] cloud_formation_endpoint ('cloudformation.us-east-1.amazonaws.com')
70
+ # The service endpoint for AWS CloudFormation.
71
+ #
69
72
  # @attr_reader [String] dynamo_db_endpoint ('dynamodb.us-east-1.amazonaws.com')
70
73
  # The service endpoint for Amazon DynamoDB.
71
74
  #
@@ -354,7 +357,7 @@ module AWS
354
357
  value || begin
355
358
  endpoint = config.send("#{ruby_name}_endpoint")
356
359
  if endpoint =~ /us-gov/
357
- if matches = enpoint.match(/(us-gov-west-\d+)/)
360
+ if matches = endpoint.match(/(us-gov-west-\d+)/)
358
361
  matches[1]
359
362
  else
360
363
  'us-gov-west-1' # e.g. iam.us-gov.amazonaws.com
@@ -153,6 +153,22 @@ module AWS
153
153
  end
154
154
 
155
155
  class << self
156
+
157
+ # @private
158
+ def define_attribute_type type_name
159
+ class_eval <<-METHODS
160
+
161
+ def self.#{type_name}_attributes
162
+ @#{type_name}_attributes ||= {}
163
+ end
164
+
165
+ def self.#{type_name}_attribute name, options = {}, &block
166
+ attr = attribute(name, options, &block)
167
+ #{type_name}_attributes[attr.name] = attr
168
+ end
169
+
170
+ METHODS
171
+ end
156
172
 
157
173
  # @private
158
174
  def new_from request_type, resp_obj, *args
@@ -73,11 +73,13 @@ module AWS
73
73
  # @return [Boolean] Returns true if the http request was throttled
74
74
  # by AWS.
75
75
  def throttled?
76
- !successful? and
77
- http_response.body and
78
- parsed_body = XmlGrammar.parse(http_response.body) and
79
- parsed_body.respond_to?(:code) and
80
- parsed_body.code == "Throttling"
76
+ if !successful? and http_response.body
77
+ error = XmlGrammar.parse(http_response.body)
78
+ error = error.error if error.respond_to?(:error)
79
+ error.respond_to?(:code) and error.code == "Throttling"
80
+ else
81
+ false
82
+ end
81
83
  end
82
84
 
83
85
  # @return [Boolean] Returns true if the http request timed out.
@@ -14,10 +14,24 @@
14
14
  module AWS
15
15
  class EC2
16
16
 
17
- #
18
17
  # @attr_reader [String,nil] instance_id Returns the instance id if
19
18
  # assigned to an EC2 instance, nil otherwise.
20
19
  #
20
+ # @attr_reader [String,nil] allocation_id
21
+ # The ID representing the allocation of the address for use with Amazon
22
+ # VPC.
23
+ #
24
+ # @attr_reader [String] Indicates whether this elastic ip address is for
25
+ # EC2 instances ('standard') or VPC instances ('vpc').
26
+ #
27
+ # @attr_reader [String,nil] The ID of the association between this elastic
28
+ # ip address and an EC2 VPC instance (VPC only).
29
+ #
30
+ # @attr_reader [String,nil] The ID of the network interface (VPC only).
31
+ #
32
+ # @attr_reader [String,nil] network_interface_owner_id
33
+ # The ID of the AWS account that owns the network interface (VPC only).
34
+ #
21
35
  class ElasticIp < Resource
22
36
 
23
37
  def initialize public_ip, options = {}
@@ -32,10 +46,27 @@ module AWS
32
46
 
33
47
  attribute :instance_id
34
48
 
49
+ ## vpc related attributes
50
+
51
+ attribute :allocation_id, :static => true
52
+
53
+ attribute :domain, :static => true
54
+
55
+ attribute :association_id
56
+
57
+ attribute :network_interface_id
58
+
59
+ attribute :network_interface_owner_id
60
+
35
61
  populates_from(:describe_addresses) do |resp|
36
62
  resp.address_index[public_ip]
37
63
  end
38
64
 
65
+ # @return [Boolean] Returns true if this is an EC2 VPC Elastic IP.
66
+ def vpc?
67
+ domain == 'vpc'
68
+ end
69
+
39
70
  # @return [Boolean] Returns true if this IP address is attached to
40
71
  # an EC2 instance.
41
72
  def associated?
@@ -59,10 +90,13 @@ module AWS
59
90
  #
60
91
  # @return [nil]
61
92
  def delete
62
- client.release_address(resource_options)
93
+ if vpc?
94
+ client.release_address(:allocation_id => allocation_id)
95
+ else
96
+ client.release_address(:public_ip => public_ip)
97
+ end
63
98
  nil
64
99
  end
65
-
66
100
  alias_method :release, :delete
67
101
 
68
102
  # Disassociates this elastic IP address from an EC2 instance.
@@ -70,10 +104,25 @@ module AWS
70
104
  # associated with an instance.
71
105
  # @return [nil]
72
106
  def disassociate
73
- client.disassociate_address(resource_options)
107
+ if vpc?
108
+ client.disassociate_address(:association_id => association_id)
109
+ else
110
+ client.disassociate_address(:public_ip => public_ip)
111
+ end
74
112
  nil
75
113
  end
76
114
 
115
+ # @return [Boolean] Returns true the elastic ip address exists in
116
+ # your account.
117
+ def exists?
118
+ begin
119
+ get_resource
120
+ true
121
+ rescue Errors::InvalidAddress::NotFound
122
+ false
123
+ end
124
+ end
125
+
77
126
  # @return [String] Returns the public IP address
78
127
  def to_s
79
128
  public_ip.to_s