aws-sdk-cloudformation 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
@@ -0,0 +1,23 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module CloudFormation
10
+ module Errors
11
+
12
+ extend Aws::Errors::DynamicErrors
13
+
14
+ # Raised when calling #load or #data on a resource class that can not be
15
+ # loaded. This can happen when:
16
+ #
17
+ # * A resource class has identifiers, but no data attributes.
18
+ # * Resource data is only available when making an API call that
19
+ # enumerates all resources of that type.
20
+ class ResourceNotLoadable < RuntimeError; end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,148 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module CloudFormation
10
+ class Event
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(id, options = {})
15
+ # @param [String] id
16
+ # @option options [Client] :client
17
+ # @overload def initialize(options = {})
18
+ # @option options [required, String] :id
19
+ # @option options [Client] :client
20
+ def initialize(*args)
21
+ options = Hash === args.last ? args.pop.dup : {}
22
+ @id = extract_id(args, options)
23
+ @data = options.delete(:data)
24
+ @client = options.delete(:client) || Client.new(options)
25
+ end
26
+
27
+ # @!group Read-Only Attributes
28
+
29
+ # @return [String]
30
+ def id
31
+ @id
32
+ end
33
+ alias :event_id :id
34
+
35
+ # The unique ID name of the instance of the stack.
36
+ # @return [String]
37
+ def stack_id
38
+ data.stack_id
39
+ end
40
+
41
+ # The name associated with a stack.
42
+ # @return [String]
43
+ def stack_name
44
+ data.stack_name
45
+ end
46
+
47
+ # The logical name of the resource specified in the template.
48
+ # @return [String]
49
+ def logical_resource_id
50
+ data.logical_resource_id
51
+ end
52
+
53
+ # The name or unique identifier associated with the physical instance of
54
+ # the resource.
55
+ # @return [String]
56
+ def physical_resource_id
57
+ data.physical_resource_id
58
+ end
59
+
60
+ # Type of resource. (For more information, go to [ AWS Resource Types
61
+ # Reference][1] in the AWS CloudFormation User Guide.)
62
+ #
63
+ #
64
+ #
65
+ # [1]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html
66
+ # @return [String]
67
+ def resource_type
68
+ data.resource_type
69
+ end
70
+
71
+ # Time the status was updated.
72
+ # @return [Time]
73
+ def timestamp
74
+ data.timestamp
75
+ end
76
+
77
+ # Current status of the resource.
78
+ # @return [String]
79
+ def resource_status
80
+ data.resource_status
81
+ end
82
+
83
+ # Success/failure message associated with the resource.
84
+ # @return [String]
85
+ def resource_status_reason
86
+ data.resource_status_reason
87
+ end
88
+
89
+ # BLOB of the properties used to create the resource.
90
+ # @return [String]
91
+ def resource_properties
92
+ data.resource_properties
93
+ end
94
+
95
+ # @!endgroup
96
+
97
+ # @return [Client]
98
+ def client
99
+ @client
100
+ end
101
+
102
+ # @raise [Errors::ResourceNotLoadable]
103
+ # @api private
104
+ def load
105
+ msg = "#load is not implemented, data only available via enumeration"
106
+ raise Errors::ResourceNotLoadable, msg
107
+ end
108
+ alias :reload :load
109
+
110
+ # @raise [Errors::ResourceNotLoadableError] Raises when {#data_loaded?} is `false`.
111
+ # @return [Types::StackEvent]
112
+ # Returns the data for this {Event}.
113
+ def data
114
+ load unless @data
115
+ @data
116
+ end
117
+
118
+ # @return [Boolean]
119
+ # Returns `true` if this resource is loaded. Accessing attributes or
120
+ # {#data} on an unloaded resource will trigger a call to {#load}.
121
+ def data_loaded?
122
+ !!@data
123
+ end
124
+
125
+ # @deprecated
126
+ # @api private
127
+ def identifiers
128
+ { id: @id }
129
+ end
130
+ deprecated(:identifiers)
131
+
132
+ private
133
+
134
+ def extract_id(args, options)
135
+ value = args[0] || options.delete(:id)
136
+ case value
137
+ when String then value
138
+ when nil then raise ArgumentError, "missing required option :id"
139
+ else
140
+ msg = "expected :id to be a String, got #{value.class}"
141
+ raise ArgumentError, msg
142
+ end
143
+ end
144
+
145
+ class Collection < Aws::Resources::Collection; end
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,271 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing for info on making contributions:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws
9
+ module CloudFormation
10
+ class Resource
11
+
12
+ # @param options ({})
13
+ # @option options [Client] :client
14
+ def initialize(options = {})
15
+ @client = options[:client] || Client.new(options)
16
+ end
17
+
18
+ # @return [Client]
19
+ def client
20
+ @client
21
+ end
22
+
23
+ # @!group Actions
24
+
25
+ # @example Request syntax with placeholder values
26
+ #
27
+ # stack = cloud_formation.create_stack({
28
+ # stack_name: "StackName", # required
29
+ # template_body: "TemplateBody",
30
+ # template_url: "TemplateURL",
31
+ # parameters: [
32
+ # {
33
+ # parameter_key: "ParameterKey",
34
+ # parameter_value: "ParameterValue",
35
+ # use_previous_value: false,
36
+ # },
37
+ # ],
38
+ # disable_rollback: false,
39
+ # timeout_in_minutes: 1,
40
+ # notification_arns: ["NotificationARN"],
41
+ # capabilities: ["CAPABILITY_IAM"], # accepts CAPABILITY_IAM, CAPABILITY_NAMED_IAM
42
+ # resource_types: ["ResourceType"],
43
+ # role_arn: "RoleARN",
44
+ # on_failure: "DO_NOTHING", # accepts DO_NOTHING, ROLLBACK, DELETE
45
+ # stack_policy_body: "StackPolicyBody",
46
+ # stack_policy_url: "StackPolicyURL",
47
+ # tags: [
48
+ # {
49
+ # key: "TagKey",
50
+ # value: "TagValue",
51
+ # },
52
+ # ],
53
+ # })
54
+ # @param [Hash] options ({})
55
+ # @option options [required, String] :stack_name
56
+ # The name that is associated with the stack. The name must be unique in
57
+ # the region in which you are creating the stack.
58
+ #
59
+ # <note markdown="1"> A stack name can contain only alphanumeric characters (case sensitive)
60
+ # and hyphens. It must start with an alphabetic character and cannot be
61
+ # longer than 128 characters.
62
+ #
63
+ # </note>
64
+ # @option options [String] :template_body
65
+ # Structure containing the template body with a minimum length of 1 byte
66
+ # and a maximum length of 51,200 bytes. For more information, go to
67
+ # [Template Anatomy][1] in the AWS CloudFormation User Guide.
68
+ #
69
+ # Conditional: You must specify either the `TemplateBody` or the
70
+ # `TemplateURL` parameter, but not both.
71
+ #
72
+ #
73
+ #
74
+ # [1]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html
75
+ # @option options [String] :template_url
76
+ # Location of file containing the template body. The URL must point to a
77
+ # template (max size: 460,800 bytes) that is located in an Amazon S3
78
+ # bucket. For more information, go to the [Template Anatomy][1] in the
79
+ # AWS CloudFormation User Guide.
80
+ #
81
+ # Conditional: You must specify either the `TemplateBody` or the
82
+ # `TemplateURL` parameter, but not both.
83
+ #
84
+ #
85
+ #
86
+ # [1]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html
87
+ # @option options [Array<Types::Parameter>] :parameters
88
+ # A list of `Parameter` structures that specify input parameters for the
89
+ # stack. For more information, see the [Parameter][1] data type.
90
+ #
91
+ #
92
+ #
93
+ # [1]: http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_Parameter.html
94
+ # @option options [Boolean] :disable_rollback
95
+ # Set to `true` to disable rollback of the stack if stack creation
96
+ # failed. You can specify either `DisableRollback` or `OnFailure`, but
97
+ # not both.
98
+ #
99
+ # Default: `false`
100
+ # @option options [Integer] :timeout_in_minutes
101
+ # The amount of time that can pass before the stack status becomes
102
+ # CREATE\_FAILED; if `DisableRollback` is not set or is set to `false`,
103
+ # the stack will be rolled back.
104
+ # @option options [Array<String>] :notification_arns
105
+ # The Simple Notification Service (SNS) topic ARNs to publish stack
106
+ # related events. You can find your SNS topic ARNs using the [SNS
107
+ # console][1] or your Command Line Interface (CLI).
108
+ #
109
+ #
110
+ #
111
+ # [1]: https://console.aws.amazon.com/sns
112
+ # @option options [Array<String>] :capabilities
113
+ # A list of values that you must specify before AWS CloudFormation can
114
+ # create certain stacks. Some stack templates might include resources
115
+ # that can affect permissions in your AWS account, for example, by
116
+ # creating new AWS Identity and Access Management (IAM) users. For those
117
+ # stacks, you must explicitly acknowledge their capabilities by
118
+ # specifying this parameter.
119
+ #
120
+ # The only valid values are `CAPABILITY_IAM` and `CAPABILITY_NAMED_IAM`.
121
+ # The following resources require you to specify this parameter: [
122
+ # AWS::IAM::AccessKey][1], [ AWS::IAM::Group][2], [
123
+ # AWS::IAM::InstanceProfile][3], [ AWS::IAM::Policy][4], [
124
+ # AWS::IAM::Role][5], [ AWS::IAM::User][6], and [
125
+ # AWS::IAM::UserToGroupAddition][7]. If your stack template contains
126
+ # these resources, we recommend that you review all permissions
127
+ # associated with them and edit their permissions if necessary.
128
+ #
129
+ # If you have IAM resources, you can specify either capability. If you
130
+ # have IAM resources with custom names, you must specify
131
+ # `CAPABILITY_NAMED_IAM`. If you don't specify this parameter, this
132
+ # action returns an `InsufficientCapabilities` error.
133
+ #
134
+ # For more information, see [Acknowledging IAM Resources in AWS
135
+ # CloudFormation Templates][8].
136
+ #
137
+ #
138
+ #
139
+ # [1]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-accesskey.html
140
+ # [2]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-group.html
141
+ # [3]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-instanceprofile.html
142
+ # [4]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-policy.html
143
+ # [5]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html
144
+ # [6]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-user.html
145
+ # [7]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-addusertogroup.html
146
+ # [8]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html#capabilities
147
+ # @option options [Array<String>] :resource_types
148
+ # The template resource types that you have permissions to work with for
149
+ # this create stack action, such as `AWS::EC2::Instance`, `AWS::EC2::*`,
150
+ # or `Custom::MyCustomInstance`. Use the following syntax to describe
151
+ # template resource types: `AWS::*` (for all AWS resource), `Custom::*`
152
+ # (for all custom resources), `Custom::logical_ID ` (for a specific
153
+ # custom resource), `AWS::service_name::*` (for all resources of a
154
+ # particular AWS service), and `AWS::service_name::resource_logical_ID `
155
+ # (for a specific AWS resource).
156
+ #
157
+ # If the list of resource types doesn't include a resource that you're
158
+ # creating, the stack creation fails. By default, AWS CloudFormation
159
+ # grants permissions to all resource types. AWS Identity and Access
160
+ # Management (IAM) uses this parameter for AWS CloudFormation-specific
161
+ # condition keys in IAM policies. For more information, see [Controlling
162
+ # Access with AWS Identity and Access Management][1].
163
+ #
164
+ #
165
+ #
166
+ # [1]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html
167
+ # @option options [String] :role_arn
168
+ # The Amazon Resource Name (ARN) of an AWS Identity and Access
169
+ # Management (IAM) role that AWS CloudFormation assumes to create the
170
+ # stack. AWS CloudFormation uses the role's credentials to make calls
171
+ # on your behalf. AWS CloudFormation always uses this role for all
172
+ # future operations on the stack. As long as users have permission to
173
+ # operate on the stack, AWS CloudFormation uses this role even if the
174
+ # users don't have permission to pass it. Ensure that the role grants
175
+ # least privilege.
176
+ #
177
+ # If you don't specify a value, AWS CloudFormation uses the role that
178
+ # was previously associated with the stack. If no role is available, AWS
179
+ # CloudFormation uses a temporary session that is generated from your
180
+ # user credentials.
181
+ # @option options [String] :on_failure
182
+ # Determines what action will be taken if stack creation fails. This
183
+ # must be one of: DO\_NOTHING, ROLLBACK, or DELETE. You can specify
184
+ # either `OnFailure` or `DisableRollback`, but not both.
185
+ #
186
+ # Default: `ROLLBACK`
187
+ # @option options [String] :stack_policy_body
188
+ # Structure containing the stack policy body. For more information, go
189
+ # to [ Prevent Updates to Stack Resources][1] in the *AWS CloudFormation
190
+ # User Guide*. You can specify either the `StackPolicyBody` or the
191
+ # `StackPolicyURL` parameter, but not both.
192
+ #
193
+ #
194
+ #
195
+ # [1]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html
196
+ # @option options [String] :stack_policy_url
197
+ # Location of a file containing the stack policy. The URL must point to
198
+ # a policy (maximum size: 16 KB) located in an S3 bucket in the same
199
+ # region as the stack. You can specify either the `StackPolicyBody` or
200
+ # the `StackPolicyURL` parameter, but not both.
201
+ # @option options [Array<Types::Tag>] :tags
202
+ # Key-value pairs to associate with this stack. AWS CloudFormation also
203
+ # propagates these tags to the resources created in the stack. A maximum
204
+ # number of 10 tags can be specified.
205
+ # @return [Stack]
206
+ def create_stack(options = {})
207
+ resp = @client.create_stack(options)
208
+ Stack.new(
209
+ name: options[:stack_name],
210
+ client: @client
211
+ )
212
+ end
213
+
214
+ # @!group Associations
215
+
216
+ # @param [String] id
217
+ # @return [Event]
218
+ def event(id)
219
+ Event.new(
220
+ id: id,
221
+ client: @client
222
+ )
223
+ end
224
+
225
+ # @param [String] name
226
+ # @return [Stack]
227
+ def stack(name)
228
+ Stack.new(
229
+ name: name,
230
+ client: @client
231
+ )
232
+ end
233
+
234
+ # @example Request syntax with placeholder values
235
+ #
236
+ # stacks = cloud_formation.stacks({
237
+ # stack_name: "StackName",
238
+ # })
239
+ # @param [Hash] options ({})
240
+ # @option options [String] :stack_name
241
+ # The name or the unique stack ID that is associated with the stack,
242
+ # which are not always interchangeable:
243
+ #
244
+ # * Running stacks: You can specify either the stack's name or its
245
+ # unique stack ID.
246
+ #
247
+ # * Deleted stacks: You must specify the unique stack ID.
248
+ #
249
+ # Default: There is no default value.
250
+ # @return [Stack::Collection]
251
+ def stacks(options = {})
252
+ batches = Enumerator.new do |y|
253
+ resp = @client.describe_stacks(options)
254
+ resp.each_page do |page|
255
+ batch = []
256
+ page.data.stacks.each do |s|
257
+ batch << Stack.new(
258
+ name: s.stack_name,
259
+ data: s,
260
+ client: @client
261
+ )
262
+ end
263
+ y.yield(batch)
264
+ end
265
+ end
266
+ Stack::Collection.new(batches)
267
+ end
268
+
269
+ end
270
+ end
271
+ end