aws-sdk-ec2 1.117.0 → 1.118.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.
@@ -0,0 +1,369 @@
1
+ # WARNING ABOUT GENERATED CODE
2
+ #
3
+ # This file is generated. See the contributing guide for more information:
4
+ # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
5
+ #
6
+ # WARNING ABOUT GENERATED CODE
7
+
8
+ module Aws::EC2
9
+ class NatGateway
10
+
11
+ extend Aws::Deprecations
12
+
13
+ # @overload def initialize(id, options = {})
14
+ # @param [String] id
15
+ # @option options [Client] :client
16
+ # @overload def initialize(options = {})
17
+ # @option options [required, String] :id
18
+ # @option options [Client] :client
19
+ def initialize(*args)
20
+ options = Hash === args.last ? args.pop.dup : {}
21
+ @id = extract_id(args, options)
22
+ @data = options.delete(:data)
23
+ @client = options.delete(:client) || Client.new(options)
24
+ end
25
+
26
+ # @!group Read-Only Attributes
27
+
28
+ # @return [String]
29
+ def id
30
+ @id
31
+ end
32
+ alias :nat_gateway_id :id
33
+
34
+ # The date and time the NAT gateway was created.
35
+ # @return [Time]
36
+ def create_time
37
+ data[:create_time]
38
+ end
39
+
40
+ # The date and time the NAT gateway was deleted, if applicable.
41
+ # @return [Time]
42
+ def delete_time
43
+ data[:delete_time]
44
+ end
45
+
46
+ # If the NAT gateway could not be created, specifies the error code for
47
+ # the failure. (`InsufficientFreeAddressesInSubnet` \|
48
+ # `Gateway.NotAttached` \| `InvalidAllocationID.NotFound` \|
49
+ # `Resource.AlreadyAssociated` \| `InternalError` \|
50
+ # `InvalidSubnetID.NotFound`)
51
+ # @return [String]
52
+ def failure_code
53
+ data[:failure_code]
54
+ end
55
+
56
+ # If the NAT gateway could not be created, specifies the error message
57
+ # for the failure, that corresponds to the error code.
58
+ #
59
+ # * For InsufficientFreeAddressesInSubnet: "Subnet has insufficient
60
+ # free addresses to create this NAT gateway"
61
+ #
62
+ # * For Gateway.NotAttached: "Network vpc-xxxxxxxx has no Internet
63
+ # gateway attached"
64
+ #
65
+ # * For InvalidAllocationID.NotFound: "Elastic IP address
66
+ # eipalloc-xxxxxxxx could not be associated with this NAT gateway"
67
+ #
68
+ # * For Resource.AlreadyAssociated: "Elastic IP address
69
+ # eipalloc-xxxxxxxx is already associated"
70
+ #
71
+ # * For InternalError: "Network interface eni-xxxxxxxx, created and
72
+ # used internally by this NAT gateway is in an invalid state. Please
73
+ # try again."
74
+ #
75
+ # * For InvalidSubnetID.NotFound: "The specified subnet subnet-xxxxxxxx
76
+ # does not exist or could not be found."
77
+ # @return [String]
78
+ def failure_message
79
+ data[:failure_message]
80
+ end
81
+
82
+ # Information about the IP addresses and network interface associated
83
+ # with the NAT gateway.
84
+ # @return [Array<Types::NatGatewayAddress>]
85
+ def nat_gateway_addresses
86
+ data[:nat_gateway_addresses]
87
+ end
88
+
89
+ # Reserved. If you need to sustain traffic greater than the [documented
90
+ # limits][1], contact us through the [Support Center][2].
91
+ #
92
+ #
93
+ #
94
+ # [1]: https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html
95
+ # [2]: https://console.aws.amazon.com/support/home?
96
+ # @return [Types::ProvisionedBandwidth]
97
+ def provisioned_bandwidth
98
+ data[:provisioned_bandwidth]
99
+ end
100
+
101
+ # The state of the NAT gateway.
102
+ #
103
+ # * `pending`\: The NAT gateway is being created and is not ready to
104
+ # process traffic.
105
+ #
106
+ # * `failed`\: The NAT gateway could not be created. Check the
107
+ # `failureCode` and `failureMessage` fields for the reason.
108
+ #
109
+ # * `available`\: The NAT gateway is able to process traffic. This
110
+ # status remains until you delete the NAT gateway, and does not
111
+ # indicate the health of the NAT gateway.
112
+ #
113
+ # * `deleting`\: The NAT gateway is in the process of being terminated
114
+ # and may still be processing traffic.
115
+ #
116
+ # * `deleted`\: The NAT gateway has been terminated and is no longer
117
+ # processing traffic.
118
+ # @return [String]
119
+ def state
120
+ data[:state]
121
+ end
122
+
123
+ # The ID of the subnet in which the NAT gateway is located.
124
+ # @return [String]
125
+ def subnet_id
126
+ data[:subnet_id]
127
+ end
128
+
129
+ # The ID of the VPC in which the NAT gateway is located.
130
+ # @return [String]
131
+ def vpc_id
132
+ data[:vpc_id]
133
+ end
134
+
135
+ # The tags for the NAT gateway.
136
+ # @return [Array<Types::Tag>]
137
+ def tags
138
+ data[:tags]
139
+ end
140
+
141
+ # @!endgroup
142
+
143
+ # @return [Client]
144
+ def client
145
+ @client
146
+ end
147
+
148
+ # Loads, or reloads {#data} for the current {NatGateway}.
149
+ # Returns `self` making it possible to chain methods.
150
+ #
151
+ # nat_gateway.reload.data
152
+ #
153
+ # @return [self]
154
+ def load
155
+ resp = @client.describe_nat_gateways(nat_gateway_ids: [@id])
156
+ @data = resp.nat_gateways[0]
157
+ self
158
+ end
159
+ alias :reload :load
160
+
161
+ # @return [Types::NatGateway]
162
+ # Returns the data for this {NatGateway}. Calls
163
+ # {Client#describe_nat_gateways} if {#data_loaded?} is `false`.
164
+ def data
165
+ load unless @data
166
+ @data
167
+ end
168
+
169
+ # @return [Boolean]
170
+ # Returns `true` if this resource is loaded. Accessing attributes or
171
+ # {#data} on an unloaded resource will trigger a call to {#load}.
172
+ def data_loaded?
173
+ !!@data
174
+ end
175
+
176
+ # @deprecated Use [Aws::EC2::Client] #wait_until instead
177
+ #
178
+ # Waiter polls an API operation until a resource enters a desired
179
+ # state.
180
+ #
181
+ # @note The waiting operation is performed on a copy. The original resource remains unchanged
182
+ #
183
+ # ## Basic Usage
184
+ #
185
+ # Waiter will polls until it is successful, it fails by
186
+ # entering a terminal state, or until a maximum number of attempts
187
+ # are made.
188
+ #
189
+ # # polls in a loop until condition is true
190
+ # resource.wait_until(options) {|resource| condition}
191
+ #
192
+ # ## Example
193
+ #
194
+ # instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }
195
+ #
196
+ # ## Configuration
197
+ #
198
+ # You can configure the maximum number of polling attempts, and the
199
+ # delay (in seconds) between each polling attempt. The waiting condition is set
200
+ # by passing a block to {#wait_until}:
201
+ #
202
+ # # poll for ~25 seconds
203
+ # resource.wait_until(max_attempts:5,delay:5) {|resource|...}
204
+ #
205
+ # ## Callbacks
206
+ #
207
+ # You can be notified before each polling attempt and before each
208
+ # delay. If you throw `:success` or `:failure` from these callbacks,
209
+ # it will terminate the waiter.
210
+ #
211
+ # started_at = Time.now
212
+ # # poll for 1 hour, instead of a number of attempts
213
+ # proc = Proc.new do |attempts, response|
214
+ # throw :failure if Time.now - started_at > 3600
215
+ # end
216
+ #
217
+ # # disable max attempts
218
+ # instance.wait_until(before_wait:proc, max_attempts:nil) {...}
219
+ #
220
+ # ## Handling Errors
221
+ #
222
+ # When a waiter is successful, it returns the Resource. When a waiter
223
+ # fails, it raises an error.
224
+ #
225
+ # begin
226
+ # resource.wait_until(...)
227
+ # rescue Aws::Waiters::Errors::WaiterFailed
228
+ # # resource did not enter the desired state in time
229
+ # end
230
+ #
231
+ #
232
+ # @yield param [Resource] resource to be used in the waiting condition
233
+ #
234
+ # @raise [Aws::Waiters::Errors::FailureStateError] Raised when the waiter terminates
235
+ # because the waiter has entered a state that it will not transition
236
+ # out of, preventing success.
237
+ #
238
+ # yet successful.
239
+ #
240
+ # @raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is encountered
241
+ # while polling for a resource that is not expected.
242
+ #
243
+ # @raise [NotImplementedError] Raised when the resource does not
244
+ #
245
+ # @option options [Integer] :max_attempts (10) Maximum number of
246
+ # attempts
247
+ # @option options [Integer] :delay (10) Delay between each
248
+ # attempt in seconds
249
+ # @option options [Proc] :before_attempt (nil) Callback
250
+ # invoked before each attempt
251
+ # @option options [Proc] :before_wait (nil) Callback
252
+ # invoked before each wait
253
+ # @return [Resource] if the waiter was successful
254
+ def wait_until(options = {}, &block)
255
+ self_copy = self.dup
256
+ attempts = 0
257
+ options[:max_attempts] = 10 unless options.key?(:max_attempts)
258
+ options[:delay] ||= 10
259
+ options[:poller] = Proc.new do
260
+ attempts += 1
261
+ if block.call(self_copy)
262
+ [:success, self_copy]
263
+ else
264
+ self_copy.reload unless attempts == options[:max_attempts]
265
+ :retry
266
+ end
267
+ end
268
+ Aws::Waiters::Waiter.new(options).wait({})
269
+ end
270
+
271
+ # @!group Actions
272
+
273
+ # @example Request syntax with placeholder values
274
+ #
275
+ # tag = nat_gateway.create_tags({
276
+ # dry_run: false,
277
+ # tags: [ # required
278
+ # {
279
+ # key: "String",
280
+ # value: "String",
281
+ # },
282
+ # ],
283
+ # })
284
+ # @param [Hash] options ({})
285
+ # @option options [Boolean] :dry_run
286
+ # Checks whether you have the required permissions for the action,
287
+ # without actually making the request, and provides an error response.
288
+ # If you have the required permissions, the error response is
289
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
290
+ # @option options [required, Array<Types::Tag>] :tags
291
+ # The tags. The `value` parameter is required, but if you don't want
292
+ # the tag to have a value, specify the parameter with no value, and we
293
+ # set the value to an empty string.
294
+ # @return [Tag::Collection]
295
+ def create_tags(options = {})
296
+ batch = []
297
+ options = Aws::Util.deep_merge(options, resources: [@id])
298
+ resp = @client.create_tags(options)
299
+ options[:tags].each do |t|
300
+ batch << Tag.new(
301
+ resource_id: @id,
302
+ key: t[:key],
303
+ value: t[:value],
304
+ client: @client
305
+ )
306
+ end
307
+ Tag::Collection.new([batch], size: batch.size)
308
+ end
309
+
310
+ # @example Request syntax with placeholder values
311
+ #
312
+ # nat_gateway.delete()
313
+ # @param [Hash] options ({})
314
+ # @return [Types::DeleteNatGatewayResult]
315
+ def delete(options = {})
316
+ options = options.merge(nat_gateway_id: @id)
317
+ resp = @client.delete_nat_gateway(options)
318
+ resp.data
319
+ end
320
+
321
+ # @!group Associations
322
+
323
+ # @return [VpcAddress, nil]
324
+ def address
325
+ if data[:allocation_id]
326
+ VpcAddress.new(
327
+ allocation_id: data[:allocation_id],
328
+ client: @client
329
+ )
330
+ else
331
+ nil
332
+ end
333
+ end
334
+
335
+ # @return [Subnet, nil]
336
+ def subnet
337
+ if data[:subnet_id]
338
+ Subnet.new(
339
+ id: data[:subnet_id],
340
+ client: @client
341
+ )
342
+ else
343
+ nil
344
+ end
345
+ end
346
+
347
+ # @deprecated
348
+ # @api private
349
+ def identifiers
350
+ { id: @id }
351
+ end
352
+ deprecated(:identifiers)
353
+
354
+ private
355
+
356
+ def extract_id(args, options)
357
+ value = args[0] || options.delete(:id)
358
+ case value
359
+ when String then value
360
+ when nil then raise ArgumentError, "missing required option :id"
361
+ else
362
+ msg = "expected :id to be a String, got #{value.class}"
363
+ raise ArgumentError, msg
364
+ end
365
+ end
366
+
367
+ class Collection < Aws::Resources::Collection; end
368
+ end
369
+ end
@@ -536,6 +536,40 @@ module Aws::EC2
536
536
  )
537
537
  end
538
538
 
539
+ # @example Request syntax with placeholder values
540
+ #
541
+ # natgateway = ec2.create_nat_gateway({
542
+ # allocation_id: "AllocationId", # required
543
+ # client_token: "String",
544
+ # subnet_id: "SubnetId", # required
545
+ # })
546
+ # @param [Hash] options ({})
547
+ # @option options [required, String] :allocation_id
548
+ # The allocation ID of an Elastic IP address to associate with the NAT
549
+ # gateway. If the Elastic IP address is associated with another
550
+ # resource, you must first disassociate it.
551
+ # @option options [String] :client_token
552
+ # Unique, case-sensitive identifier that you provide to ensure the
553
+ # idempotency of the request. For more information, see [How to Ensure
554
+ # Idempotency][1].
555
+ #
556
+ # Constraint: Maximum 64 ASCII characters.
557
+ #
558
+ #
559
+ #
560
+ # [1]: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html
561
+ # @option options [required, String] :subnet_id
562
+ # The subnet in which to create the NAT gateway.
563
+ # @return [NatGateway]
564
+ def create_nat_gateway(options = {})
565
+ resp = @client.create_nat_gateway(options)
566
+ NatGateway.new(
567
+ id: resp.data.nat_gateway.nat_gateway_id,
568
+ data: resp.data.nat_gateway,
569
+ client: @client
570
+ )
571
+ end
572
+
539
573
  # @example Request syntax with placeholder values
540
574
  #
541
575
  # networkacl = ec2.create_network_acl({
@@ -1963,6 +1997,69 @@ module Aws::EC2
1963
1997
  KeyPairInfo::Collection.new(batches)
1964
1998
  end
1965
1999
 
2000
+ # @param [String] id
2001
+ # @return [NatGateway]
2002
+ def nat_gateway(id)
2003
+ NatGateway.new(
2004
+ id: id,
2005
+ client: @client
2006
+ )
2007
+ end
2008
+
2009
+ # @example Request syntax with placeholder values
2010
+ #
2011
+ # nat_gateways = ec2.nat_gateways({
2012
+ # filter: [
2013
+ # {
2014
+ # name: "String",
2015
+ # values: ["String"],
2016
+ # },
2017
+ # ],
2018
+ # nat_gateway_ids: ["String"],
2019
+ # })
2020
+ # @param [Hash] options ({})
2021
+ # @option options [Array<Types::Filter>] :filter
2022
+ # One or more filters.
2023
+ #
2024
+ # * `nat-gateway-id` - The ID of the NAT gateway.
2025
+ #
2026
+ # * `state` - The state of the NAT gateway (`pending` \| `failed` \|
2027
+ # `available` \| `deleting` \| `deleted`).
2028
+ #
2029
+ # * `subnet-id` - The ID of the subnet in which the NAT gateway resides.
2030
+ #
2031
+ # * `tag`\:&lt;key&gt; - The key/value combination of a tag assigned to
2032
+ # the resource. Use the tag key in the filter name and the tag value
2033
+ # as the filter value. For example, to find all resources that have a
2034
+ # tag with the key `Owner` and the value `TeamA`, specify `tag:Owner`
2035
+ # for the filter name and `TeamA` for the filter value.
2036
+ #
2037
+ # * `tag-key` - The key of a tag assigned to the resource. Use this
2038
+ # filter to find all resources assigned a tag with a specific key,
2039
+ # regardless of the tag value.
2040
+ #
2041
+ # * `vpc-id` - The ID of the VPC in which the NAT gateway resides.
2042
+ # @option options [Array<String>] :nat_gateway_ids
2043
+ # One or more NAT gateway IDs.
2044
+ # @return [NatGateway::Collection]
2045
+ def nat_gateways(options = {})
2046
+ batches = Enumerator.new do |y|
2047
+ resp = @client.describe_nat_gateways(options)
2048
+ resp.each_page do |page|
2049
+ batch = []
2050
+ page.data.nat_gateways.each do |n|
2051
+ batch << NatGateway.new(
2052
+ id: n.nat_gateway_id,
2053
+ data: n,
2054
+ client: @client
2055
+ )
2056
+ end
2057
+ y.yield(batch)
2058
+ end
2059
+ end
2060
+ NatGateway::Collection.new(batches)
2061
+ end
2062
+
1966
2063
  # @param [String] id
1967
2064
  # @return [NetworkAcl]
1968
2065
  def network_acl(id)