aws-sdk 1.3.9 → 1.4.0

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 (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,75 @@
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 Event
18
+ #
19
+ # You can get stack events from a {Stack} object.
20
+ #
21
+ # stack = cfm.stacks['stack-name']
22
+ # stack.events.each do |event|
23
+ # puts "#{event.timestamp}: #{event.resource_status}"
24
+ # end
25
+ #
26
+ #
27
+ class StackEvent
28
+
29
+ # @private
30
+ def initialize stack, details
31
+ @stack = stack
32
+ details.each_pair do |attr_name,attr_value|
33
+ instance_variable_set("@#{attr_name}", attr_value)
34
+ end
35
+ end
36
+
37
+ # @return [Stack] stack The stack this event belongs to.
38
+ attr_reader :stack
39
+
40
+ # @return [String] event_id The unique ID of this event.
41
+ attr_reader :event_id
42
+
43
+ # @return [String] The logical name of the resource specified
44
+ # in the template.
45
+ attr_reader :logical_resource_id
46
+
47
+ # @return [String] The name or unique identifier associated with the
48
+ # physical instance of the resource.
49
+ attr_reader :physical_resource_id
50
+
51
+ # @return [String] BLOB of the properties used to create the resource.
52
+ attr_reader :resource_properties
53
+
54
+ # @return [Symbol] Current status of the resource.
55
+ attr_reader :resource_status
56
+
57
+ # @return [String,nil] Success/failure message associated with the
58
+ # resource.
59
+ attr_reader :resource_status_reason
60
+
61
+ # @return [String] Type of the resource (e.g. 'AWS::EC2::Instance').
62
+ attr_reader :resource_type
63
+
64
+ # @return [String] The unique ID name of the instance of the stack.
65
+ attr_reader :stack_id
66
+
67
+ # @return [String] The name associated with a stack.
68
+ attr_reader :stack_name
69
+
70
+ # @return [Time] When the status was last updated.
71
+ attr_reader :timestamp
72
+
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,47 @@
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
+ class StackEventCollection
18
+
19
+ include Core::Collection::Simple
20
+
21
+ # @param [Stack] stack
22
+ # @param [Hash] options
23
+ def initialize stack, options = {}
24
+ @stack = stack
25
+ super
26
+ end
27
+
28
+ # @return [Stack]
29
+ attr_reader :stack
30
+
31
+ protected
32
+
33
+ def _each_item options = {}
34
+ options[:stack_name] = stack.name
35
+ resp = client.describe_stack_events(options)
36
+ resp.stack_events.each do |details|
37
+
38
+ event = StackEvent.new(stack, details.to_hash)
39
+
40
+ yield(event)
41
+
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -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
+ # This module provide option helpers for methods operation on stacks.
18
+ # @private
19
+ module StackOptions
20
+
21
+ protected
22
+
23
+ def apply_stack_name stack_name, options
24
+ options[:stack_name] = stack_name
25
+ end
26
+
27
+ def apply_template opts
28
+ if template = opts.delete(:template)
29
+ case template
30
+ when String
31
+ if template.match(/http/)
32
+ opts[:template_url] = template
33
+ else
34
+ opts[:template_body] = template
35
+ end
36
+ when URI then opts[:template_url] = template.to_s
37
+ when S3::S3Object then opts[:template_body] = template.read
38
+ else
39
+ opts[:template_body] = template.to_json
40
+ end
41
+ end
42
+ end
43
+
44
+ def apply_disable_rollback options
45
+ options[:disable_rollback] = options[:disable_rollback] == true
46
+ end
47
+
48
+ def apply_notification_arns options
49
+ if arns = options.delete(:notify)
50
+ options[:notification_arns] = Array(arns).collect do |topic|
51
+ topic.is_a?(SNS::Topic) ? topic.arn : topic
52
+ end
53
+ end
54
+ end
55
+
56
+ def apply_parameters options
57
+ if params = options[:parameters] and params.is_a?(Hash)
58
+ options[:parameters] = params.inject([]) do |list,(key,value)|
59
+ list << { :parameter_key => key.to_s, :parameter_value => value }
60
+ end
61
+ end
62
+ end
63
+
64
+ def apply_timeout options
65
+ if timeout = options.delete(:timeout)
66
+ options[:timeout_in_minutes] = timeout
67
+ end
68
+ end
69
+
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,53 @@
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
+ class StackOutput
17
+
18
+ # @param [Stack] stack
19
+ # @param [String] key
20
+ # @param [String] value
21
+ # @param [String] description
22
+ def initialize stack, key, value, description
23
+ @stack = stack
24
+ @key = key
25
+ @value = value
26
+ @description = description
27
+ end
28
+
29
+ # @return [Stack]
30
+ attr_reader :stack
31
+
32
+ # @return [String]
33
+ attr_reader :key
34
+
35
+ # @return [String]
36
+ attr_reader :value
37
+
38
+ # @return [String]
39
+ attr_reader :description
40
+
41
+ # @private
42
+ def eql? other
43
+ other.is_a?(StackOutput) and
44
+ other.stack == stack and
45
+ other.key == key and
46
+ other.value == value and
47
+ other.description == description
48
+ end
49
+ alias_method :==, :eql?
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,117 @@
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
+ # @attr_reader [String,nil] description
18
+ # User defined description associated with the resource.
19
+ #
20
+ # @attr_reader [String] physical_resource_id
21
+ # The name or unique identifier that corresponds to a physical instance
22
+ # ID of a resource supported by AWS CloudFormation.
23
+ #
24
+ # @attr_reader [Symbol] resource_status
25
+ # Current status of the resource.
26
+ #
27
+ # @attr_reader [String,nil] resource_status_reason
28
+ # Success/failure message associated with the resource.
29
+ #
30
+ # @attr_reader [String] resource_type
31
+ # Type of the resource (e.g. 'AWS::EC2::Instance')
32
+ #
33
+ # @attr_reader [String] stack_name
34
+ # The name associated with the stack.
35
+ #
36
+ # @attr_reader [String] stack_id
37
+ # Unique identifier of the stack.
38
+ #
39
+ # @attr_reader [Time] last_updated_timestamp
40
+ # When the status was last updated.
41
+ #
42
+ # @attr_reader [String,nil] metadata
43
+ # The JSON format content of the Metadata attribute declared for the
44
+ # resource.
45
+ #
46
+ class StackResource < Core::Resource
47
+
48
+ # @private
49
+ def initialize stack, logical_resource_id, options = {}
50
+ @stack = stack
51
+ @logical_resource_id = logical_resource_id
52
+ super
53
+ end
54
+
55
+ # @return [Stack]
56
+ attr_reader :stack
57
+
58
+ # @return [String] The logical name of the resource specified in
59
+ # the template.
60
+ attr_reader :logical_resource_id
61
+
62
+ define_attribute_type :common # return by both describe stack resource methods
63
+
64
+ define_attribute_type :detail # returned by DescribeStackResource (singular)
65
+
66
+ common_attribute :description, :static => true
67
+
68
+ common_attribute :physical_resource_id, :static => true
69
+
70
+ common_attribute :resource_status
71
+
72
+ common_attribute :resource_status_reason
73
+
74
+ common_attribute :resource_type, :static => true
75
+
76
+ common_attribute :stack_name, :static => true
77
+
78
+ common_attribute :stack_id, :static => true
79
+
80
+ # provided by DescribeStackResource
81
+
82
+ detail_attribute :last_updated_timestamp
83
+
84
+ detail_attribute :metadata
85
+
86
+ # this operation returns all attributes
87
+ populates_from(:describe_stack_resource) do |resp|
88
+ resp.stack_resource_detail if
89
+ resp.stack_resource_detail.logical_resource_id == logical_resource_id
90
+ end
91
+
92
+ # This method provides ALL attributes except :metadata. The
93
+ # :last_updated_timestamp attribute is also provided by
94
+ # a differnt name (:timestamp instead of :last_updated_timestamp).
95
+ provider(:describe_stack_resources) do |provider|
96
+ provider.find do |resp|
97
+ resp.stack_resources.find do |resource|
98
+ resource.logical_resource_id == logical_resource_id
99
+ end
100
+ end
101
+ provider.provides *common_attributes.keys
102
+ provider.provides :last_updated_timestamp, :get_as => :timestamp
103
+ end
104
+
105
+ protected
106
+
107
+ def resource_identifiers
108
+ [[:stack_name, stack.name], [:logical_resource_id, logical_resource_id]]
109
+ end
110
+
111
+ def get_resource attribute = nil
112
+ client.describe_stack_resource(resource_options)
113
+ end
114
+
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,84 @@
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
+ # = StackResourceCollection
18
+ #
19
+ # This collection represents the resources for a single {Stack}.
20
+ # You can enumerate resources, or request a specific resource
21
+ # by its logical resource id.
22
+ #
23
+ # = Other Ways to Get Resource Details
24
+ #
25
+ # If you want to get a {StackResource} by its physical resource
26
+ # id, then you should use {CloudFormation#get_resource}.
27
+ #
28
+ # You can also take a look at {Stack#resource_summaries} for
29
+ # light-weight hashes of stack resource details.
30
+ #
31
+ # @example Enumerating stack resources
32
+ #
33
+ # # enumerating all resources for a stack
34
+ # stack.resources.each do |resource|
35
+ # puts resource.resource_type + " " + resource.physical_resource_id
36
+ # end
37
+ #
38
+ # @example Getting a stack resource by its logical resource id
39
+ #
40
+ # resource = stack.resources['web']
41
+ #
42
+ class StackResourceCollection
43
+
44
+ include Core::Collection::Simple
45
+ include StackOptions
46
+
47
+ # @param [Stack] stack
48
+ # @param [Hash] options
49
+ def initialize stack, options = {}
50
+ @stack = stack
51
+ super
52
+ end
53
+
54
+ # @return [Stack]
55
+ attr_reader :stack
56
+
57
+ # @param [String] logical_resource_id
58
+ # @return [StackResource] Returns a stack resource with the given
59
+ # logical resource id.
60
+ def [] logical_resource_id
61
+ StackResource.new(stack, logical_resource_id)
62
+ end
63
+
64
+ protected
65
+
66
+ def _each_item options = {}
67
+ options[:stack_name] = stack.name
68
+ response = client.describe_stack_resources(options)
69
+ response.stack_resources.each do |details|
70
+
71
+ stack_resource = StackResource.new_from(
72
+ :describe_stack_resources,
73
+ details,
74
+ self,
75
+ details.logical_resource_id)
76
+
77
+ yield(stack_resource)
78
+
79
+ end
80
+ end
81
+
82
+ end
83
+ end
84
+ end