aws-sdk-ec2 1.0.0.rc1

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 (36) hide show
  1. checksums.yaml +7 -0
  2. data/lib/aws-sdk-ec2.rb +70 -0
  3. data/lib/aws-sdk-ec2/classic_address.rb +227 -0
  4. data/lib/aws-sdk-ec2/client.rb +14254 -0
  5. data/lib/aws-sdk-ec2/client_api.rb +6182 -0
  6. data/lib/aws-sdk-ec2/customizations.rb +21 -0
  7. data/lib/aws-sdk-ec2/customizations/instance.rb +29 -0
  8. data/lib/aws-sdk-ec2/customizations/resource.rb +18 -0
  9. data/lib/aws-sdk-ec2/dhcp_options.rb +183 -0
  10. data/lib/aws-sdk-ec2/errors.rb +23 -0
  11. data/lib/aws-sdk-ec2/image.rb +462 -0
  12. data/lib/aws-sdk-ec2/instance.rb +1570 -0
  13. data/lib/aws-sdk-ec2/internet_gateway.rb +204 -0
  14. data/lib/aws-sdk-ec2/key_pair.rb +120 -0
  15. data/lib/aws-sdk-ec2/key_pair_info.rb +122 -0
  16. data/lib/aws-sdk-ec2/network_acl.rb +341 -0
  17. data/lib/aws-sdk-ec2/network_interface.rb +474 -0
  18. data/lib/aws-sdk-ec2/network_interface_association.rb +151 -0
  19. data/lib/aws-sdk-ec2/placement_group.rb +426 -0
  20. data/lib/aws-sdk-ec2/plugins/copy_encrypted_snapshot.rb +59 -0
  21. data/lib/aws-sdk-ec2/plugins/region_validation.rb +19 -0
  22. data/lib/aws-sdk-ec2/resource.rb +2684 -0
  23. data/lib/aws-sdk-ec2/route.rb +243 -0
  24. data/lib/aws-sdk-ec2/route_table.rb +277 -0
  25. data/lib/aws-sdk-ec2/route_table_association.rb +177 -0
  26. data/lib/aws-sdk-ec2/security_group.rb +530 -0
  27. data/lib/aws-sdk-ec2/snapshot.rb +478 -0
  28. data/lib/aws-sdk-ec2/subnet.rb +972 -0
  29. data/lib/aws-sdk-ec2/tag.rb +223 -0
  30. data/lib/aws-sdk-ec2/types.rb +20124 -0
  31. data/lib/aws-sdk-ec2/volume.rb +555 -0
  32. data/lib/aws-sdk-ec2/vpc.rb +1698 -0
  33. data/lib/aws-sdk-ec2/vpc_address.rb +219 -0
  34. data/lib/aws-sdk-ec2/vpc_peering_connection.rb +265 -0
  35. data/lib/aws-sdk-ec2/waiters.rb +1334 -0
  36. metadata +107 -0
@@ -0,0 +1,1698 @@
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 EC2
10
+ class Vpc
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 :vpc_id :id
34
+
35
+ # The current state of the VPC.
36
+ # @return [String]
37
+ def state
38
+ data.state
39
+ end
40
+
41
+ # The CIDR block for the VPC.
42
+ # @return [String]
43
+ def cidr_block
44
+ data.cidr_block
45
+ end
46
+
47
+ # The ID of the set of DHCP options you've associated with the VPC (or
48
+ # `default` if the default options are associated with the VPC).
49
+ # @return [String]
50
+ def dhcp_options_id
51
+ data.dhcp_options_id
52
+ end
53
+
54
+ # Any tags assigned to the VPC.
55
+ # @return [Array<Types::Tag>]
56
+ def tags
57
+ data.tags
58
+ end
59
+
60
+ # The allowed tenancy of instances launched into the VPC.
61
+ # @return [String]
62
+ def instance_tenancy
63
+ data.instance_tenancy
64
+ end
65
+
66
+ # Indicates whether the VPC is the default VPC.
67
+ # @return [Boolean]
68
+ def is_default
69
+ data.is_default
70
+ end
71
+
72
+ # @!endgroup
73
+
74
+ # @return [Client]
75
+ def client
76
+ @client
77
+ end
78
+
79
+ # Loads, or reloads {#data} for the current {Vpc}.
80
+ # Returns `self` making it possible to chain methods.
81
+ #
82
+ # vpc.reload.data
83
+ #
84
+ # @return [self]
85
+ def load
86
+ resp = @client.describe_vpcs(vpc_ids: [@id])
87
+ @data = resp.vpcs[0]
88
+ self
89
+ end
90
+ alias :reload :load
91
+
92
+ # @return [Types::Vpc]
93
+ # Returns the data for this {Vpc}. Calls
94
+ # {Client#describe_vpcs} if {#data_loaded?} is `false`.
95
+ def data
96
+ load unless @data
97
+ @data
98
+ end
99
+
100
+ # @return [Boolean]
101
+ # Returns `true` if this resource is loaded. Accessing attributes or
102
+ # {#data} on an unloaded resource will trigger a call to {#load}.
103
+ def data_loaded?
104
+ !!@data
105
+ end
106
+
107
+ # @param [Hash] options ({})
108
+ # @return [Boolean]
109
+ # Returns `true` if the Vpc exists.
110
+ def exists?(options = {})
111
+ begin
112
+ wait_until_exists(options.merge(max_attempts: 1))
113
+ true
114
+ rescue Aws::Waiters::Errors::UnexpectedError => e
115
+ raise e.error
116
+ rescue Aws::Waiters::Errors::WaiterFailed
117
+ false
118
+ end
119
+ end
120
+
121
+ # @param [Hash] options ({})
122
+ # @option options [Integer] :max_attempts (40)
123
+ # @option options [Float] :delay (15)
124
+ # @option options [Proc] :before_attempt
125
+ # @option options [Proc] :before_wait
126
+ # @return [Vpc]
127
+ def wait_until_available(options = {})
128
+ options, params = separate_params_and_options(options)
129
+ waiter = Waiters::VpcAvailable.new(options)
130
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
131
+ waiter.wait(params.merge(vpc_ids: [@id]))
132
+ Vpc.new({
133
+ id: @id,
134
+ client: @client
135
+ })
136
+ end
137
+
138
+ # @param [Hash] options ({})
139
+ # @option options [Integer] :max_attempts (5)
140
+ # @option options [Float] :delay (1)
141
+ # @option options [Proc] :before_attempt
142
+ # @option options [Proc] :before_wait
143
+ # @return [Vpc]
144
+ def wait_until_exists(options = {})
145
+ options, params = separate_params_and_options(options)
146
+ waiter = Waiters::VpcExists.new(options)
147
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
148
+ waiter.wait(params.merge(vpc_ids: [@id]))
149
+ Vpc.new({
150
+ id: @id,
151
+ client: @client
152
+ })
153
+ end
154
+
155
+ # @!group Actions
156
+
157
+ # @example Request syntax with placeholder values
158
+ #
159
+ # vpc.associate_dhcp_options({
160
+ # dry_run: false,
161
+ # dhcp_options_id: "String", # required
162
+ # })
163
+ # @param [Hash] options ({})
164
+ # @option options [Boolean] :dry_run
165
+ # Checks whether you have the required permissions for the action,
166
+ # without actually making the request, and provides an error response.
167
+ # If you have the required permissions, the error response is
168
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
169
+ # @option options [required, String] :dhcp_options_id
170
+ # The ID of the DHCP options set, or `default` to associate no DHCP
171
+ # options with the VPC.
172
+ # @return [EmptyStructure]
173
+ def associate_dhcp_options(options = {})
174
+ options = options.merge(vpc_id: @id)
175
+ resp = @client.associate_dhcp_options(options)
176
+ resp.data
177
+ end
178
+
179
+ # @example Request syntax with placeholder values
180
+ #
181
+ # vpc.attach_classic_link_instance({
182
+ # dry_run: false,
183
+ # instance_id: "String", # required
184
+ # groups: ["String"], # required
185
+ # })
186
+ # @param [Hash] options ({})
187
+ # @option options [Boolean] :dry_run
188
+ # Checks whether you have the required permissions for the action,
189
+ # without actually making the request, and provides an error response.
190
+ # If you have the required permissions, the error response is
191
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
192
+ # @option options [required, String] :instance_id
193
+ # The ID of an EC2-Classic instance to link to the ClassicLink-enabled
194
+ # VPC.
195
+ # @option options [required, Array<String>] :groups
196
+ # The ID of one or more of the VPC's security groups. You cannot
197
+ # specify security groups from a different VPC.
198
+ # @return [Types::AttachClassicLinkVpcResult]
199
+ def attach_classic_link_instance(options = {})
200
+ options = options.merge(vpc_id: @id)
201
+ resp = @client.attach_classic_link_vpc(options)
202
+ resp.data
203
+ end
204
+
205
+ # @example Request syntax with placeholder values
206
+ #
207
+ # vpc.attach_internet_gateway({
208
+ # dry_run: false,
209
+ # internet_gateway_id: "String", # required
210
+ # })
211
+ # @param [Hash] options ({})
212
+ # @option options [Boolean] :dry_run
213
+ # Checks whether you have the required permissions for the action,
214
+ # without actually making the request, and provides an error response.
215
+ # If you have the required permissions, the error response is
216
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
217
+ # @option options [required, String] :internet_gateway_id
218
+ # The ID of the Internet gateway.
219
+ # @return [EmptyStructure]
220
+ def attach_internet_gateway(options = {})
221
+ options = options.merge(vpc_id: @id)
222
+ resp = @client.attach_internet_gateway(options)
223
+ resp.data
224
+ end
225
+
226
+ # @example Request syntax with placeholder values
227
+ #
228
+ # networkacl = vpc.create_network_acl({
229
+ # dry_run: false,
230
+ # })
231
+ # @param [Hash] options ({})
232
+ # @option options [Boolean] :dry_run
233
+ # Checks whether you have the required permissions for the action,
234
+ # without actually making the request, and provides an error response.
235
+ # If you have the required permissions, the error response is
236
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
237
+ # @return [NetworkAcl]
238
+ def create_network_acl(options = {})
239
+ options = options.merge(vpc_id: @id)
240
+ resp = @client.create_network_acl(options)
241
+ NetworkAcl.new(
242
+ id: resp.data.network_acl.network_acl_id,
243
+ data: resp.data.network_acl,
244
+ client: @client
245
+ )
246
+ end
247
+
248
+ # @example Request syntax with placeholder values
249
+ #
250
+ # routetable = vpc.create_route_table({
251
+ # dry_run: false,
252
+ # })
253
+ # @param [Hash] options ({})
254
+ # @option options [Boolean] :dry_run
255
+ # Checks whether you have the required permissions for the action,
256
+ # without actually making the request, and provides an error response.
257
+ # If you have the required permissions, the error response is
258
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
259
+ # @return [RouteTable]
260
+ def create_route_table(options = {})
261
+ options = options.merge(vpc_id: @id)
262
+ resp = @client.create_route_table(options)
263
+ RouteTable.new(
264
+ id: resp.data.route_table.route_table_id,
265
+ data: resp.data.route_table,
266
+ client: @client
267
+ )
268
+ end
269
+
270
+ # @example Request syntax with placeholder values
271
+ #
272
+ # securitygroup = vpc.create_security_group({
273
+ # dry_run: false,
274
+ # group_name: "String", # required
275
+ # description: "String", # required
276
+ # })
277
+ # @param [Hash] options ({})
278
+ # @option options [Boolean] :dry_run
279
+ # Checks whether you have the required permissions for the action,
280
+ # without actually making the request, and provides an error response.
281
+ # If you have the required permissions, the error response is
282
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
283
+ # @option options [required, String] :group_name
284
+ # The name of the security group.
285
+ #
286
+ # Constraints: Up to 255 characters in length
287
+ #
288
+ # Constraints for EC2-Classic: ASCII characters
289
+ #
290
+ # Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and
291
+ # .\_-:/()#,@\[\]+=&amp;;\\\{\\}!$*
292
+ # @option options [required, String] :description
293
+ # A description for the security group. This is informational only.
294
+ #
295
+ # Constraints: Up to 255 characters in length
296
+ #
297
+ # Constraints for EC2-Classic: ASCII characters
298
+ #
299
+ # Constraints for EC2-VPC: a-z, A-Z, 0-9, spaces, and
300
+ # .\_-:/()#,@\[\]+=&amp;;\\\{\\}!$*
301
+ # @return [SecurityGroup]
302
+ def create_security_group(options = {})
303
+ options = options.merge(vpc_id: @id)
304
+ resp = @client.create_security_group(options)
305
+ SecurityGroup.new(
306
+ id: resp.data.group_id,
307
+ client: @client
308
+ )
309
+ end
310
+
311
+ # @example Request syntax with placeholder values
312
+ #
313
+ # subnet = vpc.create_subnet({
314
+ # dry_run: false,
315
+ # cidr_block: "String", # required
316
+ # availability_zone: "String",
317
+ # })
318
+ # @param [Hash] options ({})
319
+ # @option options [Boolean] :dry_run
320
+ # Checks whether you have the required permissions for the action,
321
+ # without actually making the request, and provides an error response.
322
+ # If you have the required permissions, the error response is
323
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
324
+ # @option options [required, String] :cidr_block
325
+ # The network range for the subnet, in CIDR notation. For example,
326
+ # `10.0.0.0/24`.
327
+ # @option options [String] :availability_zone
328
+ # The Availability Zone for the subnet.
329
+ #
330
+ # Default: AWS selects one for you. If you create more than one subnet
331
+ # in your VPC, we may not necessarily select a different zone for each
332
+ # subnet.
333
+ # @return [Subnet]
334
+ def create_subnet(options = {})
335
+ options = options.merge(vpc_id: @id)
336
+ resp = @client.create_subnet(options)
337
+ Subnet.new(
338
+ id: resp.data.subnet.subnet_id,
339
+ data: resp.data.subnet,
340
+ client: @client
341
+ )
342
+ end
343
+
344
+ # @example Request syntax with placeholder values
345
+ #
346
+ # tag = vpc.create_tags({
347
+ # dry_run: false,
348
+ # tags: [ # required
349
+ # {
350
+ # key: "String",
351
+ # value: "String",
352
+ # },
353
+ # ],
354
+ # })
355
+ # @param [Hash] options ({})
356
+ # @option options [Boolean] :dry_run
357
+ # Checks whether you have the required permissions for the action,
358
+ # without actually making the request, and provides an error response.
359
+ # If you have the required permissions, the error response is
360
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
361
+ # @option options [required, Array<Types::Tag>] :tags
362
+ # One or more tags. The `value` parameter is required, but if you don't
363
+ # want the tag to have a value, specify the parameter with no value, and
364
+ # we set the value to an empty string.
365
+ # @return [Tag::Collection]
366
+ def create_tags(options = {})
367
+ batch = []
368
+ options = Aws::Util.deep_merge(options, resources: [@id])
369
+ resp = @client.create_tags(options)
370
+ options[:tags].each do |t|
371
+ batch << Tag.new(
372
+ resource_id: @id,
373
+ key: t[:key],
374
+ value: t[:value],
375
+ client: @client
376
+ )
377
+ end
378
+ Tag::Collection.new([batch], size: batch.size)
379
+ end
380
+
381
+ # @example Request syntax with placeholder values
382
+ #
383
+ # vpc.delete({
384
+ # dry_run: false,
385
+ # })
386
+ # @param [Hash] options ({})
387
+ # @option options [Boolean] :dry_run
388
+ # Checks whether you have the required permissions for the action,
389
+ # without actually making the request, and provides an error response.
390
+ # If you have the required permissions, the error response is
391
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
392
+ # @return [EmptyStructure]
393
+ def delete(options = {})
394
+ options = options.merge(vpc_id: @id)
395
+ resp = @client.delete_vpc(options)
396
+ resp.data
397
+ end
398
+
399
+ # @example Request syntax with placeholder values
400
+ #
401
+ # vpc.describe_attribute({
402
+ # dry_run: false,
403
+ # attribute: "enableDnsSupport", # required, accepts enableDnsSupport, enableDnsHostnames
404
+ # })
405
+ # @param [Hash] options ({})
406
+ # @option options [Boolean] :dry_run
407
+ # Checks whether you have the required permissions for the action,
408
+ # without actually making the request, and provides an error response.
409
+ # If you have the required permissions, the error response is
410
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
411
+ # @option options [required, String] :attribute
412
+ # The VPC attribute.
413
+ # @return [Types::DescribeVpcAttributeResult]
414
+ def describe_attribute(options = {})
415
+ options = options.merge(vpc_id: @id)
416
+ resp = @client.describe_vpc_attribute(options)
417
+ resp.data
418
+ end
419
+
420
+ # @example Request syntax with placeholder values
421
+ #
422
+ # vpc.detach_classic_link_instance({
423
+ # dry_run: false,
424
+ # instance_id: "String", # required
425
+ # })
426
+ # @param [Hash] options ({})
427
+ # @option options [Boolean] :dry_run
428
+ # Checks whether you have the required permissions for the action,
429
+ # without actually making the request, and provides an error response.
430
+ # If you have the required permissions, the error response is
431
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
432
+ # @option options [required, String] :instance_id
433
+ # The ID of the instance to unlink from the VPC.
434
+ # @return [Types::DetachClassicLinkVpcResult]
435
+ def detach_classic_link_instance(options = {})
436
+ options = options.merge(vpc_id: @id)
437
+ resp = @client.detach_classic_link_vpc(options)
438
+ resp.data
439
+ end
440
+
441
+ # @example Request syntax with placeholder values
442
+ #
443
+ # vpc.detach_internet_gateway({
444
+ # dry_run: false,
445
+ # internet_gateway_id: "String", # required
446
+ # })
447
+ # @param [Hash] options ({})
448
+ # @option options [Boolean] :dry_run
449
+ # Checks whether you have the required permissions for the action,
450
+ # without actually making the request, and provides an error response.
451
+ # If you have the required permissions, the error response is
452
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
453
+ # @option options [required, String] :internet_gateway_id
454
+ # The ID of the Internet gateway.
455
+ # @return [EmptyStructure]
456
+ def detach_internet_gateway(options = {})
457
+ options = options.merge(vpc_id: @id)
458
+ resp = @client.detach_internet_gateway(options)
459
+ resp.data
460
+ end
461
+
462
+ # @example Request syntax with placeholder values
463
+ #
464
+ # vpc.disable_classic_link({
465
+ # dry_run: false,
466
+ # })
467
+ # @param [Hash] options ({})
468
+ # @option options [Boolean] :dry_run
469
+ # Checks whether you have the required permissions for the action,
470
+ # without actually making the request, and provides an error response.
471
+ # If you have the required permissions, the error response is
472
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
473
+ # @return [Types::DisableVpcClassicLinkResult]
474
+ def disable_classic_link(options = {})
475
+ options = options.merge(vpc_id: @id)
476
+ resp = @client.disable_vpc_classic_link(options)
477
+ resp.data
478
+ end
479
+
480
+ # @example Request syntax with placeholder values
481
+ #
482
+ # vpc.enable_classic_link({
483
+ # dry_run: false,
484
+ # })
485
+ # @param [Hash] options ({})
486
+ # @option options [Boolean] :dry_run
487
+ # Checks whether you have the required permissions for the action,
488
+ # without actually making the request, and provides an error response.
489
+ # If you have the required permissions, the error response is
490
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
491
+ # @return [Types::EnableVpcClassicLinkResult]
492
+ def enable_classic_link(options = {})
493
+ options = options.merge(vpc_id: @id)
494
+ resp = @client.enable_vpc_classic_link(options)
495
+ resp.data
496
+ end
497
+
498
+ # @example Request syntax with placeholder values
499
+ #
500
+ # vpc.modify_attribute({
501
+ # enable_dns_support: {
502
+ # value: false,
503
+ # },
504
+ # enable_dns_hostnames: {
505
+ # value: false,
506
+ # },
507
+ # })
508
+ # @param [Hash] options ({})
509
+ # @option options [Types::AttributeBooleanValue] :enable_dns_support
510
+ # Indicates whether the DNS resolution is supported for the VPC. If
511
+ # enabled, queries to the Amazon provided DNS server at the
512
+ # 169.254.169.253 IP address, or the reserved IP address at the base of
513
+ # the VPC network range "plus two" will succeed. If disabled, the
514
+ # Amazon provided DNS service in the VPC that resolves public DNS
515
+ # hostnames to IP addresses is not enabled.
516
+ #
517
+ # You cannot modify the DNS resolution and DNS hostnames attributes in
518
+ # the same request. Use separate requests for each attribute.
519
+ # @option options [Types::AttributeBooleanValue] :enable_dns_hostnames
520
+ # Indicates whether the instances launched in the VPC get DNS hostnames.
521
+ # If enabled, instances in the VPC get DNS hostnames; otherwise, they do
522
+ # not.
523
+ #
524
+ # You cannot modify the DNS resolution and DNS hostnames attributes in
525
+ # the same request. Use separate requests for each attribute. You can
526
+ # only enable DNS hostnames if you've enabled DNS support.
527
+ # @return [EmptyStructure]
528
+ def modify_attribute(options = {})
529
+ options = options.merge(vpc_id: @id)
530
+ resp = @client.modify_vpc_attribute(options)
531
+ resp.data
532
+ end
533
+
534
+ # @example Request syntax with placeholder values
535
+ #
536
+ # vpcpeeringconnection = vpc.request_vpc_peering_connection({
537
+ # dry_run: false,
538
+ # peer_vpc_id: "String",
539
+ # peer_owner_id: "String",
540
+ # })
541
+ # @param [Hash] options ({})
542
+ # @option options [Boolean] :dry_run
543
+ # Checks whether you have the required permissions for the action,
544
+ # without actually making the request, and provides an error response.
545
+ # If you have the required permissions, the error response is
546
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
547
+ # @option options [String] :peer_vpc_id
548
+ # The ID of the VPC with which you are creating the VPC peering
549
+ # connection.
550
+ # @option options [String] :peer_owner_id
551
+ # The AWS account ID of the owner of the peer VPC.
552
+ #
553
+ # Default: Your AWS account ID
554
+ # @return [VpcPeeringConnection]
555
+ def request_vpc_peering_connection(options = {})
556
+ options = options.merge(vpc_id: @id)
557
+ resp = @client.create_vpc_peering_connection(options)
558
+ VpcPeeringConnection.new(
559
+ id: resp.data.vpc_peering_connection.vpc_peering_connection_id,
560
+ data: resp.data.vpc_peering_connection,
561
+ client: @client
562
+ )
563
+ end
564
+
565
+ # @!group Associations
566
+
567
+ # @example Request syntax with placeholder values
568
+ #
569
+ # acceptedvpcpeeringconnections = vpc.accepted_vpc_peering_connections({
570
+ # dry_run: false,
571
+ # vpc_peering_connection_ids: ["String"],
572
+ # filters: [
573
+ # {
574
+ # name: "String",
575
+ # values: ["String"],
576
+ # },
577
+ # ],
578
+ # })
579
+ # @param [Hash] options ({})
580
+ # @option options [Boolean] :dry_run
581
+ # Checks whether you have the required permissions for the action,
582
+ # without actually making the request, and provides an error response.
583
+ # If you have the required permissions, the error response is
584
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
585
+ # @option options [Array<String>] :vpc_peering_connection_ids
586
+ # One or more VPC peering connection IDs.
587
+ #
588
+ # Default: Describes all your VPC peering connections.
589
+ # @option options [Array<Types::Filter>] :filters
590
+ # One or more filters.
591
+ #
592
+ # * `accepter-vpc-info.cidr-block` - The CIDR block of the peer VPC.
593
+ #
594
+ # * `accepter-vpc-info.owner-id` - The AWS account ID of the owner of
595
+ # the peer VPC.
596
+ #
597
+ # * `accepter-vpc-info.vpc-id` - The ID of the peer VPC.
598
+ #
599
+ # * `expiration-time` - The expiration date and time for the VPC peering
600
+ # connection.
601
+ #
602
+ # * `requester-vpc-info.cidr-block` - The CIDR block of the requester's
603
+ # VPC.
604
+ #
605
+ # * `requester-vpc-info.owner-id` - The AWS account ID of the owner of
606
+ # the requester VPC.
607
+ #
608
+ # * `requester-vpc-info.vpc-id` - The ID of the requester VPC.
609
+ #
610
+ # * `status-code` - The status of the VPC peering connection
611
+ # (`pending-acceptance` \| `failed` \| `expired` \| `provisioning` \|
612
+ # `active` \| `deleted` \| `rejected`).
613
+ #
614
+ # * `status-message` - A message that provides more information about
615
+ # the status of the VPC peering connection, if applicable.
616
+ #
617
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
618
+ # to the resource.
619
+ #
620
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
621
+ # is independent of the `tag-value` filter. For example, if you use
622
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
623
+ # you get any resources assigned both the tag key Purpose (regardless
624
+ # of what the tag's value is), and the tag value X (regardless of
625
+ # what the tag's key is). If you want to list only resources where
626
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
627
+ #
628
+ # * `tag-value` - The value of a tag assigned to the resource. This
629
+ # filter is independent of the `tag-key` filter.
630
+ #
631
+ # * `vpc-peering-connection-id` - The ID of the VPC peering connection.
632
+ # @return [VpcPeeringConnection::Collection]
633
+ def accepted_vpc_peering_connections(options = {})
634
+ batches = Enumerator.new do |y|
635
+ batch = []
636
+ options = Aws::Util.deep_merge(options, filters: [{
637
+ name: "accepter-vpc-info.vpc-id",
638
+ values: [@id]
639
+ }])
640
+ resp = @client.describe_vpc_peering_connections(options)
641
+ resp.data.vpc_peering_connections.each do |v|
642
+ batch << VpcPeeringConnection.new(
643
+ id: v.vpc_peering_connection_id,
644
+ data: v,
645
+ client: @client
646
+ )
647
+ end
648
+ y.yield(batch)
649
+ end
650
+ VpcPeeringConnection::Collection.new(batches)
651
+ end
652
+
653
+ # @return [DhcpOptions, nil]
654
+ def dhcp_options
655
+ if data.dhcp_options_id
656
+ DhcpOptions.new(
657
+ id: data.dhcp_options_id,
658
+ client: @client
659
+ )
660
+ else
661
+ nil
662
+ end
663
+ end
664
+
665
+ # @example Request syntax with placeholder values
666
+ #
667
+ # instances = vpc.instances({
668
+ # dry_run: false,
669
+ # instance_ids: ["String"],
670
+ # filters: [
671
+ # {
672
+ # name: "String",
673
+ # values: ["String"],
674
+ # },
675
+ # ],
676
+ # })
677
+ # @param [Hash] options ({})
678
+ # @option options [Boolean] :dry_run
679
+ # Checks whether you have the required permissions for the action,
680
+ # without actually making the request, and provides an error response.
681
+ # If you have the required permissions, the error response is
682
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
683
+ # @option options [Array<String>] :instance_ids
684
+ # One or more instance IDs.
685
+ #
686
+ # Default: Describes all your instances.
687
+ # @option options [Array<Types::Filter>] :filters
688
+ # One or more filters.
689
+ #
690
+ # * `affinity` - The affinity setting for an instance running on a
691
+ # Dedicated Host (`default` \| `host`).
692
+ #
693
+ # * `architecture` - The instance architecture (`i386` \| `x86_64`).
694
+ #
695
+ # * `availability-zone` - The Availability Zone of the instance.
696
+ #
697
+ # * `block-device-mapping.attach-time` - The attach time for an EBS
698
+ # volume mapped to the instance, for example,
699
+ # `2010-09-15T17:15:20.000Z`.
700
+ #
701
+ # * `block-device-mapping.delete-on-termination` - A Boolean that
702
+ # indicates whether the EBS volume is deleted on instance termination.
703
+ #
704
+ # * `block-device-mapping.device-name` - The device name for the EBS
705
+ # volume (for example, `/dev/sdh` or `xvdh`).
706
+ #
707
+ # * `block-device-mapping.status` - The status for the EBS volume
708
+ # (`attaching` \| `attached` \| `detaching` \| `detached`).
709
+ #
710
+ # * `block-device-mapping.volume-id` - The volume ID of the EBS volume.
711
+ #
712
+ # * `client-token` - The idempotency token you provided when you
713
+ # launched the instance.
714
+ #
715
+ # * `dns-name` - The public DNS name of the instance.
716
+ #
717
+ # * `group-id` - The ID of the security group for the instance.
718
+ # EC2-Classic only.
719
+ #
720
+ # * `group-name` - The name of the security group for the instance.
721
+ # EC2-Classic only.
722
+ #
723
+ # * `host-id` - The ID of the Dedicated Host on which the instance is
724
+ # running, if applicable.
725
+ #
726
+ # * `hypervisor` - The hypervisor type of the instance (`ovm` \| `xen`).
727
+ #
728
+ # * `iam-instance-profile.arn` - The instance profile associated with
729
+ # the instance. Specified as an ARN.
730
+ #
731
+ # * `image-id` - The ID of the image used to launch the instance.
732
+ #
733
+ # * `instance-id` - The ID of the instance.
734
+ #
735
+ # * `instance-lifecycle` - Indicates whether this is a Spot Instance or
736
+ # a Scheduled Instance (`spot` \| `scheduled`).
737
+ #
738
+ # * `instance-state-code` - The state of the instance, as a 16-bit
739
+ # unsigned integer. The high byte is an opaque internal value and
740
+ # should be ignored. The low byte is set based on the state
741
+ # represented. The valid values are: 0 (pending), 16 (running), 32
742
+ # (shutting-down), 48 (terminated), 64 (stopping), and 80 (stopped).
743
+ #
744
+ # * `instance-state-name` - The state of the instance (`pending` \|
745
+ # `running` \| `shutting-down` \| `terminated` \| `stopping` \|
746
+ # `stopped`).
747
+ #
748
+ # * `instance-type` - The type of instance (for example, `t2.micro`).
749
+ #
750
+ # * `instance.group-id` - The ID of the security group for the instance.
751
+ #
752
+ # * `instance.group-name` - The name of the security group for the
753
+ # instance.
754
+ #
755
+ # * `ip-address` - The public IP address of the instance.
756
+ #
757
+ # * `kernel-id` - The kernel ID.
758
+ #
759
+ # * `key-name` - The name of the key pair used when the instance was
760
+ # launched.
761
+ #
762
+ # * `launch-index` - When launching multiple instances, this is the
763
+ # index for the instance in the launch group (for example, 0, 1, 2,
764
+ # and so on).
765
+ #
766
+ # * `launch-time` - The time when the instance was launched.
767
+ #
768
+ # * `monitoring-state` - Indicates whether monitoring is enabled for the
769
+ # instance (`disabled` \| `enabled`).
770
+ #
771
+ # * `owner-id` - The AWS account ID of the instance owner.
772
+ #
773
+ # * `placement-group-name` - The name of the placement group for the
774
+ # instance.
775
+ #
776
+ # * `platform` - The platform. Use `windows` if you have Windows
777
+ # instances; otherwise, leave blank.
778
+ #
779
+ # * `private-dns-name` - The private DNS name of the instance.
780
+ #
781
+ # * `private-ip-address` - The private IP address of the instance.
782
+ #
783
+ # * `product-code` - The product code associated with the AMI used to
784
+ # launch the instance.
785
+ #
786
+ # * `product-code.type` - The type of product code (`devpay` \|
787
+ # `marketplace`).
788
+ #
789
+ # * `ramdisk-id` - The RAM disk ID.
790
+ #
791
+ # * `reason` - The reason for the current state of the instance (for
792
+ # example, shows "User Initiated \[date\]" when you stop or
793
+ # terminate the instance). Similar to the state-reason-code filter.
794
+ #
795
+ # * `requester-id` - The ID of the entity that launched the instance on
796
+ # your behalf (for example, AWS Management Console, Auto Scaling, and
797
+ # so on).
798
+ #
799
+ # * `reservation-id` - The ID of the instance's reservation. A
800
+ # reservation ID is created any time you launch an instance. A
801
+ # reservation ID has a one-to-one relationship with an instance launch
802
+ # request, but can be associated with more than one instance if you
803
+ # launch multiple instances using the same launch request. For
804
+ # example, if you launch one instance, you'll get one reservation ID.
805
+ # If you launch ten instances using the same launch request, you'll
806
+ # also get one reservation ID.
807
+ #
808
+ # * `root-device-name` - The name of the root device for the instance
809
+ # (for example, `/dev/sda1` or `/dev/xvda`).
810
+ #
811
+ # * `root-device-type` - The type of root device that the instance uses
812
+ # (`ebs` \| `instance-store`).
813
+ #
814
+ # * `source-dest-check` - Indicates whether the instance performs
815
+ # source/destination checking. A value of `true` means that checking
816
+ # is enabled, and `false` means checking is disabled. The value must
817
+ # be `false` for the instance to perform network address translation
818
+ # (NAT) in your VPC.
819
+ #
820
+ # * `spot-instance-request-id` - The ID of the Spot instance request.
821
+ #
822
+ # * `state-reason-code` - The reason code for the state change.
823
+ #
824
+ # * `state-reason-message` - A message that describes the state change.
825
+ #
826
+ # * `subnet-id` - The ID of the subnet for the instance.
827
+ #
828
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
829
+ # to the resource, where `tag`\:*key* is the tag's key.
830
+ #
831
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
832
+ # is independent of the `tag-value` filter. For example, if you use
833
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
834
+ # you get any resources assigned both the tag key Purpose (regardless
835
+ # of what the tag's value is), and the tag value X (regardless of
836
+ # what the tag's key is). If you want to list only resources where
837
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
838
+ #
839
+ # * `tag-value` - The value of a tag assigned to the resource. This
840
+ # filter is independent of the `tag-key` filter.
841
+ #
842
+ # * `tenancy` - The tenancy of an instance (`dedicated` \| `default` \|
843
+ # `host`).
844
+ #
845
+ # * `virtualization-type` - The virtualization type of the instance
846
+ # (`paravirtual` \| `hvm`).
847
+ #
848
+ # * `vpc-id` - The ID of the VPC that the instance is running in.
849
+ #
850
+ # * `network-interface.description` - The description of the network
851
+ # interface.
852
+ #
853
+ # * `network-interface.subnet-id` - The ID of the subnet for the network
854
+ # interface.
855
+ #
856
+ # * `network-interface.vpc-id` - The ID of the VPC for the network
857
+ # interface.
858
+ #
859
+ # * `network-interface.network-interface-id` - The ID of the network
860
+ # interface.
861
+ #
862
+ # * `network-interface.owner-id` - The ID of the owner of the network
863
+ # interface.
864
+ #
865
+ # * `network-interface.availability-zone` - The Availability Zone for
866
+ # the network interface.
867
+ #
868
+ # * `network-interface.requester-id` - The requester ID for the network
869
+ # interface.
870
+ #
871
+ # * `network-interface.requester-managed` - Indicates whether the
872
+ # network interface is being managed by AWS.
873
+ #
874
+ # * `network-interface.status` - The status of the network interface
875
+ # (`available`) \| `in-use`).
876
+ #
877
+ # * `network-interface.mac-address` - The MAC address of the network
878
+ # interface.
879
+ #
880
+ # * `network-interface.private-dns-name` - The private DNS name of the
881
+ # network interface.
882
+ #
883
+ # * `network-interface.source-dest-check` - Whether the network
884
+ # interface performs source/destination checking. A value of `true`
885
+ # means checking is enabled, and `false` means checking is disabled.
886
+ # The value must be `false` for the network interface to perform
887
+ # network address translation (NAT) in your VPC.
888
+ #
889
+ # * `network-interface.group-id` - The ID of a security group associated
890
+ # with the network interface.
891
+ #
892
+ # * `network-interface.group-name` - The name of a security group
893
+ # associated with the network interface.
894
+ #
895
+ # * `network-interface.attachment.attachment-id` - The ID of the
896
+ # interface attachment.
897
+ #
898
+ # * `network-interface.attachment.instance-id` - The ID of the instance
899
+ # to which the network interface is attached.
900
+ #
901
+ # * `network-interface.attachment.instance-owner-id` - The owner ID of
902
+ # the instance to which the network interface is attached.
903
+ #
904
+ # * `network-interface.addresses.private-ip-address` - The private IP
905
+ # address associated with the network interface.
906
+ #
907
+ # * `network-interface.attachment.device-index` - The device index to
908
+ # which the network interface is attached.
909
+ #
910
+ # * `network-interface.attachment.status` - The status of the attachment
911
+ # (`attaching` \| `attached` \| `detaching` \| `detached`).
912
+ #
913
+ # * `network-interface.attachment.attach-time` - The time that the
914
+ # network interface was attached to an instance.
915
+ #
916
+ # * `network-interface.attachment.delete-on-termination` - Specifies
917
+ # whether the attachment is deleted when an instance is terminated.
918
+ #
919
+ # * `network-interface.addresses.primary` - Specifies whether the IP
920
+ # address of the network interface is the primary private IP address.
921
+ #
922
+ # * `network-interface.addresses.association.public-ip` - The ID of the
923
+ # association of an Elastic IP address with a network interface.
924
+ #
925
+ # * `network-interface.addresses.association.ip-owner-id` - The owner ID
926
+ # of the private IP address associated with the network interface.
927
+ #
928
+ # * `association.public-ip` - The address of the Elastic IP address
929
+ # bound to the network interface.
930
+ #
931
+ # * `association.ip-owner-id` - The owner of the Elastic IP address
932
+ # associated with the network interface.
933
+ #
934
+ # * `association.allocation-id` - The allocation ID returned when you
935
+ # allocated the Elastic IP address for your network interface.
936
+ #
937
+ # * `association.association-id` - The association ID returned when the
938
+ # network interface was associated with an IP address.
939
+ # @return [Instance::Collection]
940
+ def instances(options = {})
941
+ batches = Enumerator.new do |y|
942
+ options = Aws::Util.deep_merge(options, filters: [{
943
+ name: "vpc-id",
944
+ values: [@id]
945
+ }])
946
+ resp = @client.describe_instances(options)
947
+ resp.each_page do |page|
948
+ batch = []
949
+ page.data.reservations.each do |r|
950
+ r.instances.each do |i|
951
+ batch << Instance.new(
952
+ id: i.instance_id,
953
+ data: i,
954
+ client: @client
955
+ )
956
+ end
957
+ end
958
+ y.yield(batch)
959
+ end
960
+ end
961
+ Instance::Collection.new(batches)
962
+ end
963
+
964
+ # @example Request syntax with placeholder values
965
+ #
966
+ # internetgateways = vpc.internet_gateways({
967
+ # dry_run: false,
968
+ # internet_gateway_ids: ["String"],
969
+ # filters: [
970
+ # {
971
+ # name: "String",
972
+ # values: ["String"],
973
+ # },
974
+ # ],
975
+ # })
976
+ # @param [Hash] options ({})
977
+ # @option options [Boolean] :dry_run
978
+ # Checks whether you have the required permissions for the action,
979
+ # without actually making the request, and provides an error response.
980
+ # If you have the required permissions, the error response is
981
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
982
+ # @option options [Array<String>] :internet_gateway_ids
983
+ # One or more Internet gateway IDs.
984
+ #
985
+ # Default: Describes all your Internet gateways.
986
+ # @option options [Array<Types::Filter>] :filters
987
+ # One or more filters.
988
+ #
989
+ # * `attachment.state` - The current state of the attachment between the
990
+ # gateway and the VPC (`available`). Present only if a VPC is
991
+ # attached.
992
+ #
993
+ # * `attachment.vpc-id` - The ID of an attached VPC.
994
+ #
995
+ # * `internet-gateway-id` - The ID of the Internet gateway.
996
+ #
997
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
998
+ # to the resource.
999
+ #
1000
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
1001
+ # is independent of the `tag-value` filter. For example, if you use
1002
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
1003
+ # you get any resources assigned both the tag key Purpose (regardless
1004
+ # of what the tag's value is), and the tag value X (regardless of
1005
+ # what the tag's key is). If you want to list only resources where
1006
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
1007
+ #
1008
+ # * `tag-value` - The value of a tag assigned to the resource. This
1009
+ # filter is independent of the `tag-key` filter.
1010
+ # @return [InternetGateway::Collection]
1011
+ def internet_gateways(options = {})
1012
+ batches = Enumerator.new do |y|
1013
+ batch = []
1014
+ options = Aws::Util.deep_merge(options, filters: [{
1015
+ name: "attachment.vpc-id",
1016
+ values: [@id]
1017
+ }])
1018
+ resp = @client.describe_internet_gateways(options)
1019
+ resp.data.internet_gateways.each do |i|
1020
+ batch << InternetGateway.new(
1021
+ id: i.internet_gateway_id,
1022
+ data: i,
1023
+ client: @client
1024
+ )
1025
+ end
1026
+ y.yield(batch)
1027
+ end
1028
+ InternetGateway::Collection.new(batches)
1029
+ end
1030
+
1031
+ # @example Request syntax with placeholder values
1032
+ #
1033
+ # networkacls = vpc.network_acls({
1034
+ # dry_run: false,
1035
+ # network_acl_ids: ["String"],
1036
+ # filters: [
1037
+ # {
1038
+ # name: "String",
1039
+ # values: ["String"],
1040
+ # },
1041
+ # ],
1042
+ # })
1043
+ # @param [Hash] options ({})
1044
+ # @option options [Boolean] :dry_run
1045
+ # Checks whether you have the required permissions for the action,
1046
+ # without actually making the request, and provides an error response.
1047
+ # If you have the required permissions, the error response is
1048
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1049
+ # @option options [Array<String>] :network_acl_ids
1050
+ # One or more network ACL IDs.
1051
+ #
1052
+ # Default: Describes all your network ACLs.
1053
+ # @option options [Array<Types::Filter>] :filters
1054
+ # One or more filters.
1055
+ #
1056
+ # * `association.association-id` - The ID of an association ID for the
1057
+ # ACL.
1058
+ #
1059
+ # * `association.network-acl-id` - The ID of the network ACL involved in
1060
+ # the association.
1061
+ #
1062
+ # * `association.subnet-id` - The ID of the subnet involved in the
1063
+ # association.
1064
+ #
1065
+ # * `default` - Indicates whether the ACL is the default network ACL for
1066
+ # the VPC.
1067
+ #
1068
+ # * `entry.cidr` - The CIDR range specified in the entry.
1069
+ #
1070
+ # * `entry.egress` - Indicates whether the entry applies to egress
1071
+ # traffic.
1072
+ #
1073
+ # * `entry.icmp.code` - The ICMP code specified in the entry, if any.
1074
+ #
1075
+ # * `entry.icmp.type` - The ICMP type specified in the entry, if any.
1076
+ #
1077
+ # * `entry.port-range.from` - The start of the port range specified in
1078
+ # the entry.
1079
+ #
1080
+ # * `entry.port-range.to` - The end of the port range specified in the
1081
+ # entry.
1082
+ #
1083
+ # * `entry.protocol` - The protocol specified in the entry (`tcp` \|
1084
+ # `udp` \| `icmp` or a protocol number).
1085
+ #
1086
+ # * `entry.rule-action` - Allows or denies the matching traffic (`allow`
1087
+ # \| `deny`).
1088
+ #
1089
+ # * `entry.rule-number` - The number of an entry (in other words, rule)
1090
+ # in the ACL's set of entries.
1091
+ #
1092
+ # * `network-acl-id` - The ID of the network ACL.
1093
+ #
1094
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
1095
+ # to the resource.
1096
+ #
1097
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
1098
+ # is independent of the `tag-value` filter. For example, if you use
1099
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
1100
+ # you get any resources assigned both the tag key Purpose (regardless
1101
+ # of what the tag's value is), and the tag value X (regardless of
1102
+ # what the tag's key is). If you want to list only resources where
1103
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
1104
+ #
1105
+ # * `tag-value` - The value of a tag assigned to the resource. This
1106
+ # filter is independent of the `tag-key` filter.
1107
+ #
1108
+ # * `vpc-id` - The ID of the VPC for the network ACL.
1109
+ # @return [NetworkAcl::Collection]
1110
+ def network_acls(options = {})
1111
+ batches = Enumerator.new do |y|
1112
+ batch = []
1113
+ options = Aws::Util.deep_merge(options, filters: [{
1114
+ name: "vpc-id",
1115
+ values: [@id]
1116
+ }])
1117
+ resp = @client.describe_network_acls(options)
1118
+ resp.data.network_acls.each do |n|
1119
+ batch << NetworkAcl.new(
1120
+ id: n.network_acl_id,
1121
+ data: n,
1122
+ client: @client
1123
+ )
1124
+ end
1125
+ y.yield(batch)
1126
+ end
1127
+ NetworkAcl::Collection.new(batches)
1128
+ end
1129
+
1130
+ # @example Request syntax with placeholder values
1131
+ #
1132
+ # networkinterfaces = vpc.network_interfaces({
1133
+ # dry_run: false,
1134
+ # network_interface_ids: ["String"],
1135
+ # filters: [
1136
+ # {
1137
+ # name: "String",
1138
+ # values: ["String"],
1139
+ # },
1140
+ # ],
1141
+ # })
1142
+ # @param [Hash] options ({})
1143
+ # @option options [Boolean] :dry_run
1144
+ # Checks whether you have the required permissions for the action,
1145
+ # without actually making the request, and provides an error response.
1146
+ # If you have the required permissions, the error response is
1147
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1148
+ # @option options [Array<String>] :network_interface_ids
1149
+ # One or more network interface IDs.
1150
+ #
1151
+ # Default: Describes all your network interfaces.
1152
+ # @option options [Array<Types::Filter>] :filters
1153
+ # One or more filters.
1154
+ #
1155
+ # * `addresses.private-ip-address` - The private IP addresses associated
1156
+ # with the network interface.
1157
+ #
1158
+ # * `addresses.primary` - Whether the private IP address is the primary
1159
+ # IP address associated with the network interface.
1160
+ #
1161
+ # * `addresses.association.public-ip` - The association ID returned when
1162
+ # the network interface was associated with the Elastic IP address.
1163
+ #
1164
+ # * `addresses.association.owner-id` - The owner ID of the addresses
1165
+ # associated with the network interface.
1166
+ #
1167
+ # * `association.association-id` - The association ID returned when the
1168
+ # network interface was associated with an IP address.
1169
+ #
1170
+ # * `association.allocation-id` - The allocation ID returned when you
1171
+ # allocated the Elastic IP address for your network interface.
1172
+ #
1173
+ # * `association.ip-owner-id` - The owner of the Elastic IP address
1174
+ # associated with the network interface.
1175
+ #
1176
+ # * `association.public-ip` - The address of the Elastic IP address
1177
+ # bound to the network interface.
1178
+ #
1179
+ # * `association.public-dns-name` - The public DNS name for the network
1180
+ # interface.
1181
+ #
1182
+ # * `attachment.attachment-id` - The ID of the interface attachment.
1183
+ #
1184
+ # * `attachment.attach.time` - The time that the network interface was
1185
+ # attached to an instance.
1186
+ #
1187
+ # * `attachment.delete-on-termination` - Indicates whether the
1188
+ # attachment is deleted when an instance is terminated.
1189
+ #
1190
+ # * `attachment.device-index` - The device index to which the network
1191
+ # interface is attached.
1192
+ #
1193
+ # * `attachment.instance-id` - The ID of the instance to which the
1194
+ # network interface is attached.
1195
+ #
1196
+ # * `attachment.instance-owner-id` - The owner ID of the instance to
1197
+ # which the network interface is attached.
1198
+ #
1199
+ # * `attachment.nat-gateway-id` - The ID of the NAT gateway to which the
1200
+ # network interface is attached.
1201
+ #
1202
+ # * `attachment.status` - The status of the attachment (`attaching` \|
1203
+ # `attached` \| `detaching` \| `detached`).
1204
+ #
1205
+ # * `availability-zone` - The Availability Zone of the network
1206
+ # interface.
1207
+ #
1208
+ # * `description` - The description of the network interface.
1209
+ #
1210
+ # * `group-id` - The ID of a security group associated with the network
1211
+ # interface.
1212
+ #
1213
+ # * `group-name` - The name of a security group associated with the
1214
+ # network interface.
1215
+ #
1216
+ # * `mac-address` - The MAC address of the network interface.
1217
+ #
1218
+ # * `network-interface-id` - The ID of the network interface.
1219
+ #
1220
+ # * `owner-id` - The AWS account ID of the network interface owner.
1221
+ #
1222
+ # * `private-ip-address` - The private IP address or addresses of the
1223
+ # network interface.
1224
+ #
1225
+ # * `private-dns-name` - The private DNS name of the network interface.
1226
+ #
1227
+ # * `requester-id` - The ID of the entity that launched the instance on
1228
+ # your behalf (for example, AWS Management Console, Auto Scaling, and
1229
+ # so on).
1230
+ #
1231
+ # * `requester-managed` - Indicates whether the network interface is
1232
+ # being managed by an AWS service (for example, AWS Management
1233
+ # Console, Auto Scaling, and so on).
1234
+ #
1235
+ # * `source-desk-check` - Indicates whether the network interface
1236
+ # performs source/destination checking. A value of `true` means
1237
+ # checking is enabled, and `false` means checking is disabled. The
1238
+ # value must be `false` for the network interface to perform network
1239
+ # address translation (NAT) in your VPC.
1240
+ #
1241
+ # * `status` - The status of the network interface. If the network
1242
+ # interface is not attached to an instance, the status is `available`;
1243
+ # if a network interface is attached to an instance the status is
1244
+ # `in-use`.
1245
+ #
1246
+ # * `subnet-id` - The ID of the subnet for the network interface.
1247
+ #
1248
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
1249
+ # to the resource.
1250
+ #
1251
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
1252
+ # is independent of the `tag-value` filter. For example, if you use
1253
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
1254
+ # you get any resources assigned both the tag key Purpose (regardless
1255
+ # of what the tag's value is), and the tag value X (regardless of
1256
+ # what the tag's key is). If you want to list only resources where
1257
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
1258
+ #
1259
+ # * `tag-value` - The value of a tag assigned to the resource. This
1260
+ # filter is independent of the `tag-key` filter.
1261
+ #
1262
+ # * `vpc-id` - The ID of the VPC for the network interface.
1263
+ # @return [NetworkInterface::Collection]
1264
+ def network_interfaces(options = {})
1265
+ batches = Enumerator.new do |y|
1266
+ batch = []
1267
+ options = Aws::Util.deep_merge(options, filters: [{
1268
+ name: "vpc-id",
1269
+ values: [@id]
1270
+ }])
1271
+ resp = @client.describe_network_interfaces(options)
1272
+ resp.data.network_interfaces.each do |n|
1273
+ batch << NetworkInterface.new(
1274
+ id: n.network_interface_id,
1275
+ data: n,
1276
+ client: @client
1277
+ )
1278
+ end
1279
+ y.yield(batch)
1280
+ end
1281
+ NetworkInterface::Collection.new(batches)
1282
+ end
1283
+
1284
+ # @example Request syntax with placeholder values
1285
+ #
1286
+ # requestedvpcpeeringconnections = vpc.requested_vpc_peering_connections({
1287
+ # dry_run: false,
1288
+ # vpc_peering_connection_ids: ["String"],
1289
+ # filters: [
1290
+ # {
1291
+ # name: "String",
1292
+ # values: ["String"],
1293
+ # },
1294
+ # ],
1295
+ # })
1296
+ # @param [Hash] options ({})
1297
+ # @option options [Boolean] :dry_run
1298
+ # Checks whether you have the required permissions for the action,
1299
+ # without actually making the request, and provides an error response.
1300
+ # If you have the required permissions, the error response is
1301
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1302
+ # @option options [Array<String>] :vpc_peering_connection_ids
1303
+ # One or more VPC peering connection IDs.
1304
+ #
1305
+ # Default: Describes all your VPC peering connections.
1306
+ # @option options [Array<Types::Filter>] :filters
1307
+ # One or more filters.
1308
+ #
1309
+ # * `accepter-vpc-info.cidr-block` - The CIDR block of the peer VPC.
1310
+ #
1311
+ # * `accepter-vpc-info.owner-id` - The AWS account ID of the owner of
1312
+ # the peer VPC.
1313
+ #
1314
+ # * `accepter-vpc-info.vpc-id` - The ID of the peer VPC.
1315
+ #
1316
+ # * `expiration-time` - The expiration date and time for the VPC peering
1317
+ # connection.
1318
+ #
1319
+ # * `requester-vpc-info.cidr-block` - The CIDR block of the requester's
1320
+ # VPC.
1321
+ #
1322
+ # * `requester-vpc-info.owner-id` - The AWS account ID of the owner of
1323
+ # the requester VPC.
1324
+ #
1325
+ # * `requester-vpc-info.vpc-id` - The ID of the requester VPC.
1326
+ #
1327
+ # * `status-code` - The status of the VPC peering connection
1328
+ # (`pending-acceptance` \| `failed` \| `expired` \| `provisioning` \|
1329
+ # `active` \| `deleted` \| `rejected`).
1330
+ #
1331
+ # * `status-message` - A message that provides more information about
1332
+ # the status of the VPC peering connection, if applicable.
1333
+ #
1334
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
1335
+ # to the resource.
1336
+ #
1337
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
1338
+ # is independent of the `tag-value` filter. For example, if you use
1339
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
1340
+ # you get any resources assigned both the tag key Purpose (regardless
1341
+ # of what the tag's value is), and the tag value X (regardless of
1342
+ # what the tag's key is). If you want to list only resources where
1343
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
1344
+ #
1345
+ # * `tag-value` - The value of a tag assigned to the resource. This
1346
+ # filter is independent of the `tag-key` filter.
1347
+ #
1348
+ # * `vpc-peering-connection-id` - The ID of the VPC peering connection.
1349
+ # @return [VpcPeeringConnection::Collection]
1350
+ def requested_vpc_peering_connections(options = {})
1351
+ batches = Enumerator.new do |y|
1352
+ batch = []
1353
+ options = Aws::Util.deep_merge(options, filters: [{
1354
+ name: "requester-vpc-info.vpc-id",
1355
+ values: [@id]
1356
+ }])
1357
+ resp = @client.describe_vpc_peering_connections(options)
1358
+ resp.data.vpc_peering_connections.each do |v|
1359
+ batch << VpcPeeringConnection.new(
1360
+ id: v.vpc_peering_connection_id,
1361
+ data: v,
1362
+ client: @client
1363
+ )
1364
+ end
1365
+ y.yield(batch)
1366
+ end
1367
+ VpcPeeringConnection::Collection.new(batches)
1368
+ end
1369
+
1370
+ # @example Request syntax with placeholder values
1371
+ #
1372
+ # routetables = vpc.route_tables({
1373
+ # dry_run: false,
1374
+ # route_table_ids: ["String"],
1375
+ # filters: [
1376
+ # {
1377
+ # name: "String",
1378
+ # values: ["String"],
1379
+ # },
1380
+ # ],
1381
+ # })
1382
+ # @param [Hash] options ({})
1383
+ # @option options [Boolean] :dry_run
1384
+ # Checks whether you have the required permissions for the action,
1385
+ # without actually making the request, and provides an error response.
1386
+ # If you have the required permissions, the error response is
1387
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1388
+ # @option options [Array<String>] :route_table_ids
1389
+ # One or more route table IDs.
1390
+ #
1391
+ # Default: Describes all your route tables.
1392
+ # @option options [Array<Types::Filter>] :filters
1393
+ # One or more filters.
1394
+ #
1395
+ # * `association.route-table-association-id` - The ID of an association
1396
+ # ID for the route table.
1397
+ #
1398
+ # * `association.route-table-id` - The ID of the route table involved in
1399
+ # the association.
1400
+ #
1401
+ # * `association.subnet-id` - The ID of the subnet involved in the
1402
+ # association.
1403
+ #
1404
+ # * `association.main` - Indicates whether the route table is the main
1405
+ # route table for the VPC (`true` \| `false`).
1406
+ #
1407
+ # * `route-table-id` - The ID of the route table.
1408
+ #
1409
+ # * `route.destination-cidr-block` - The CIDR range specified in a route
1410
+ # in the table.
1411
+ #
1412
+ # * `route.destination-prefix-list-id` - The ID (prefix) of the AWS
1413
+ # service specified in a route in the table.
1414
+ #
1415
+ # * `route.gateway-id` - The ID of a gateway specified in a route in the
1416
+ # table.
1417
+ #
1418
+ # * `route.instance-id` - The ID of an instance specified in a route in
1419
+ # the table.
1420
+ #
1421
+ # * `route.nat-gateway-id` - The ID of a NAT gateway.
1422
+ #
1423
+ # * `route.origin` - Describes how the route was created.
1424
+ # `CreateRouteTable` indicates that the route was automatically
1425
+ # created when the route table was created; `CreateRoute` indicates
1426
+ # that the route was manually added to the route table;
1427
+ # `EnableVgwRoutePropagation` indicates that the route was propagated
1428
+ # by route propagation.
1429
+ #
1430
+ # * `route.state` - The state of a route in the route table (`active` \|
1431
+ # `blackhole`). The blackhole state indicates that the route's target
1432
+ # isn't available (for example, the specified gateway isn't attached
1433
+ # to the VPC, the specified NAT instance has been terminated, and so
1434
+ # on).
1435
+ #
1436
+ # * `route.vpc-peering-connection-id` - The ID of a VPC peering
1437
+ # connection specified in a route in the table.
1438
+ #
1439
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
1440
+ # to the resource.
1441
+ #
1442
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
1443
+ # is independent of the `tag-value` filter. For example, if you use
1444
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
1445
+ # you get any resources assigned both the tag key Purpose (regardless
1446
+ # of what the tag's value is), and the tag value X (regardless of
1447
+ # what the tag's key is). If you want to list only resources where
1448
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
1449
+ #
1450
+ # * `tag-value` - The value of a tag assigned to the resource. This
1451
+ # filter is independent of the `tag-key` filter.
1452
+ #
1453
+ # * `vpc-id` - The ID of the VPC for the route table.
1454
+ # @return [RouteTable::Collection]
1455
+ def route_tables(options = {})
1456
+ batches = Enumerator.new do |y|
1457
+ batch = []
1458
+ options = Aws::Util.deep_merge(options, filters: [{
1459
+ name: "vpc-id",
1460
+ values: [@id]
1461
+ }])
1462
+ resp = @client.describe_route_tables(options)
1463
+ resp.data.route_tables.each do |r|
1464
+ batch << RouteTable.new(
1465
+ id: r.route_table_id,
1466
+ data: r,
1467
+ client: @client
1468
+ )
1469
+ end
1470
+ y.yield(batch)
1471
+ end
1472
+ RouteTable::Collection.new(batches)
1473
+ end
1474
+
1475
+ # @example Request syntax with placeholder values
1476
+ #
1477
+ # securitygroups = vpc.security_groups({
1478
+ # dry_run: false,
1479
+ # group_names: ["String"],
1480
+ # group_ids: ["String"],
1481
+ # filters: [
1482
+ # {
1483
+ # name: "String",
1484
+ # values: ["String"],
1485
+ # },
1486
+ # ],
1487
+ # })
1488
+ # @param [Hash] options ({})
1489
+ # @option options [Boolean] :dry_run
1490
+ # Checks whether you have the required permissions for the action,
1491
+ # without actually making the request, and provides an error response.
1492
+ # If you have the required permissions, the error response is
1493
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1494
+ # @option options [Array<String>] :group_names
1495
+ # \[EC2-Classic and default VPC only\] One or more security group names.
1496
+ # You can specify either the security group name or the security group
1497
+ # ID. For security groups in a nondefault VPC, use the `group-name`
1498
+ # filter to describe security groups by name.
1499
+ #
1500
+ # Default: Describes all your security groups.
1501
+ # @option options [Array<String>] :group_ids
1502
+ # One or more security group IDs. Required for security groups in a
1503
+ # nondefault VPC.
1504
+ #
1505
+ # Default: Describes all your security groups.
1506
+ # @option options [Array<Types::Filter>] :filters
1507
+ # One or more filters. If using multiple filters for rules, the results
1508
+ # include security groups for which any combination of rules - not
1509
+ # necessarily a single rule - match all filters.
1510
+ #
1511
+ # * `description` - The description of the security group.
1512
+ #
1513
+ # * `egress.ip-permission.prefix-list-id` - The ID (prefix) of the AWS
1514
+ # service to which the security group allows access.
1515
+ #
1516
+ # * `group-id` - The ID of the security group.
1517
+ #
1518
+ # * `group-name` - The name of the security group.
1519
+ #
1520
+ # * `ip-permission.cidr` - A CIDR range that has been granted
1521
+ # permission.
1522
+ #
1523
+ # * `ip-permission.from-port` - The start of port range for the TCP and
1524
+ # UDP protocols, or an ICMP type number.
1525
+ #
1526
+ # * `ip-permission.group-id` - The ID of a security group that has been
1527
+ # granted permission.
1528
+ #
1529
+ # * `ip-permission.group-name` - The name of a security group that has
1530
+ # been granted permission.
1531
+ #
1532
+ # * `ip-permission.protocol` - The IP protocol for the permission (`tcp`
1533
+ # \| `udp` \| `icmp` or a protocol number).
1534
+ #
1535
+ # * `ip-permission.to-port` - The end of port range for the TCP and UDP
1536
+ # protocols, or an ICMP code.
1537
+ #
1538
+ # * `ip-permission.user-id` - The ID of an AWS account that has been
1539
+ # granted permission.
1540
+ #
1541
+ # * `owner-id` - The AWS account ID of the owner of the security group.
1542
+ #
1543
+ # * `tag-key` - The key of a tag assigned to the security group.
1544
+ #
1545
+ # * `tag-value` - The value of a tag assigned to the security group.
1546
+ #
1547
+ # * `vpc-id` - The ID of the VPC specified when the security group was
1548
+ # created.
1549
+ # @return [SecurityGroup::Collection]
1550
+ def security_groups(options = {})
1551
+ batches = Enumerator.new do |y|
1552
+ batch = []
1553
+ options = Aws::Util.deep_merge(options, filters: [{
1554
+ name: "vpc-id",
1555
+ values: [@id]
1556
+ }])
1557
+ resp = @client.describe_security_groups(options)
1558
+ resp.data.security_groups.each do |s|
1559
+ batch << SecurityGroup.new(
1560
+ id: s.group_id,
1561
+ data: s,
1562
+ client: @client
1563
+ )
1564
+ end
1565
+ y.yield(batch)
1566
+ end
1567
+ SecurityGroup::Collection.new(batches)
1568
+ end
1569
+
1570
+ # @example Request syntax with placeholder values
1571
+ #
1572
+ # subnets = vpc.subnets({
1573
+ # dry_run: false,
1574
+ # subnet_ids: ["String"],
1575
+ # filters: [
1576
+ # {
1577
+ # name: "String",
1578
+ # values: ["String"],
1579
+ # },
1580
+ # ],
1581
+ # })
1582
+ # @param [Hash] options ({})
1583
+ # @option options [Boolean] :dry_run
1584
+ # Checks whether you have the required permissions for the action,
1585
+ # without actually making the request, and provides an error response.
1586
+ # If you have the required permissions, the error response is
1587
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1588
+ # @option options [Array<String>] :subnet_ids
1589
+ # One or more subnet IDs.
1590
+ #
1591
+ # Default: Describes all your subnets.
1592
+ # @option options [Array<Types::Filter>] :filters
1593
+ # One or more filters.
1594
+ #
1595
+ # * `availabilityZone` - The Availability Zone for the subnet. You can
1596
+ # also use `availability-zone` as the filter name.
1597
+ #
1598
+ # * `available-ip-address-count` - The number of IP addresses in the
1599
+ # subnet that are available.
1600
+ #
1601
+ # * `cidrBlock` - The CIDR block of the subnet. The CIDR block you
1602
+ # specify must exactly match the subnet's CIDR block for information
1603
+ # to be returned for the subnet. You can also use `cidr` or
1604
+ # `cidr-block` as the filter names.
1605
+ #
1606
+ # * `defaultForAz` - Indicates whether this is the default subnet for
1607
+ # the Availability Zone. You can also use `default-for-az` as the
1608
+ # filter name.
1609
+ #
1610
+ # * `state` - The state of the subnet (`pending` \| `available`).
1611
+ #
1612
+ # * `subnet-id` - The ID of the subnet.
1613
+ #
1614
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
1615
+ # to the resource.
1616
+ #
1617
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
1618
+ # is independent of the `tag-value` filter. For example, if you use
1619
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
1620
+ # you get any resources assigned both the tag key Purpose (regardless
1621
+ # of what the tag's value is), and the tag value X (regardless of
1622
+ # what the tag's key is). If you want to list only resources where
1623
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
1624
+ #
1625
+ # * `tag-value` - The value of a tag assigned to the resource. This
1626
+ # filter is independent of the `tag-key` filter.
1627
+ #
1628
+ # * `vpc-id` - The ID of the VPC for the subnet.
1629
+ # @return [Subnet::Collection]
1630
+ def subnets(options = {})
1631
+ batches = Enumerator.new do |y|
1632
+ batch = []
1633
+ options = Aws::Util.deep_merge(options, filters: [{
1634
+ name: "vpc-id",
1635
+ values: [@id]
1636
+ }])
1637
+ resp = @client.describe_subnets(options)
1638
+ resp.data.subnets.each do |s|
1639
+ batch << Subnet.new(
1640
+ id: s.subnet_id,
1641
+ data: s,
1642
+ client: @client
1643
+ )
1644
+ end
1645
+ y.yield(batch)
1646
+ end
1647
+ Subnet::Collection.new(batches)
1648
+ end
1649
+
1650
+ # @deprecated
1651
+ # @api private
1652
+ def identifiers
1653
+ { id: @id }
1654
+ end
1655
+ deprecated(:identifiers)
1656
+
1657
+ private
1658
+
1659
+ def extract_id(args, options)
1660
+ value = args[0] || options.delete(:id)
1661
+ case value
1662
+ when String then value
1663
+ when nil then raise ArgumentError, "missing required option :id"
1664
+ else
1665
+ msg = "expected :id to be a String, got #{value.class}"
1666
+ raise ArgumentError, msg
1667
+ end
1668
+ end
1669
+
1670
+ def yield_waiter_and_warn(waiter, &block)
1671
+ if !@waiter_block_warned
1672
+ msg = "pass options to configure the waiter; "
1673
+ msg << "yielding the waiter is deprecated"
1674
+ warn(msg)
1675
+ @waiter_block_warned = true
1676
+ end
1677
+ yield(waiter.waiter)
1678
+ end
1679
+
1680
+ def separate_params_and_options(options)
1681
+ opts = Set.new([:client, :max_attempts, :delay, :before_attempt, :before_wait])
1682
+ waiter_opts = {}
1683
+ waiter_params = {}
1684
+ options.each_pair do |key, value|
1685
+ if opts.include?(key)
1686
+ waiter_opts[key] = value
1687
+ else
1688
+ waiter_params[key] = value
1689
+ end
1690
+ end
1691
+ waiter_opts[:client] ||= @client
1692
+ [waiter_opts, waiter_params]
1693
+ end
1694
+
1695
+ class Collection < Aws::Resources::Collection; end
1696
+ end
1697
+ end
1698
+ end