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,1570 @@
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 Instance
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 :instance_id :id
34
+
35
+ # The ID of the AMI used to launch the instance.
36
+ # @return [String]
37
+ def image_id
38
+ data.image_id
39
+ end
40
+
41
+ # The current state of the instance.
42
+ # @return [Types::InstanceState]
43
+ def state
44
+ data.state
45
+ end
46
+
47
+ # The private DNS name assigned to the instance. This DNS name can only
48
+ # be used inside the Amazon EC2 network. This name is not available
49
+ # until the instance enters the `running` state. For EC2-VPC, this name
50
+ # is only available if you've enabled DNS hostnames for your VPC.
51
+ # @return [String]
52
+ def private_dns_name
53
+ data.private_dns_name
54
+ end
55
+
56
+ # The public DNS name assigned to the instance. This name is not
57
+ # available until the instance enters the `running` state. For EC2-VPC,
58
+ # this name is only available if you've enabled DNS hostnames for your
59
+ # VPC.
60
+ # @return [String]
61
+ def public_dns_name
62
+ data.public_dns_name
63
+ end
64
+
65
+ # The reason for the most recent state transition. This might be an
66
+ # empty string.
67
+ # @return [String]
68
+ def state_transition_reason
69
+ data.state_transition_reason
70
+ end
71
+
72
+ # The name of the key pair, if this instance was launched with an
73
+ # associated key pair.
74
+ # @return [String]
75
+ def key_name
76
+ data.key_name
77
+ end
78
+
79
+ # The AMI launch index, which can be used to find this instance in the
80
+ # launch group.
81
+ # @return [Integer]
82
+ def ami_launch_index
83
+ data.ami_launch_index
84
+ end
85
+
86
+ # The product codes attached to this instance, if applicable.
87
+ # @return [Array<Types::ProductCode>]
88
+ def product_codes
89
+ data.product_codes
90
+ end
91
+
92
+ # The instance type.
93
+ # @return [String]
94
+ def instance_type
95
+ data.instance_type
96
+ end
97
+
98
+ # The time the instance was launched.
99
+ # @return [Time]
100
+ def launch_time
101
+ data.launch_time
102
+ end
103
+
104
+ # The location where the instance launched, if applicable.
105
+ # @return [Types::Placement]
106
+ def placement
107
+ data.placement
108
+ end
109
+
110
+ # The kernel associated with this instance, if applicable.
111
+ # @return [String]
112
+ def kernel_id
113
+ data.kernel_id
114
+ end
115
+
116
+ # The RAM disk associated with this instance, if applicable.
117
+ # @return [String]
118
+ def ramdisk_id
119
+ data.ramdisk_id
120
+ end
121
+
122
+ # The value is `Windows` for Windows instances; otherwise blank.
123
+ # @return [String]
124
+ def platform
125
+ data.platform
126
+ end
127
+
128
+ # The monitoring information for the instance.
129
+ # @return [Types::Monitoring]
130
+ def monitoring
131
+ data.monitoring
132
+ end
133
+
134
+ # \[EC2-VPC\] The ID of the subnet in which the instance is running.
135
+ # @return [String]
136
+ def subnet_id
137
+ data.subnet_id
138
+ end
139
+
140
+ # \[EC2-VPC\] The ID of the VPC in which the instance is running.
141
+ # @return [String]
142
+ def vpc_id
143
+ data.vpc_id
144
+ end
145
+
146
+ # The private IP address assigned to the instance.
147
+ # @return [String]
148
+ def private_ip_address
149
+ data.private_ip_address
150
+ end
151
+
152
+ # The public IP address assigned to the instance, if applicable.
153
+ # @return [String]
154
+ def public_ip_address
155
+ data.public_ip_address
156
+ end
157
+
158
+ # The reason for the most recent state transition.
159
+ # @return [Types::StateReason]
160
+ def state_reason
161
+ data.state_reason
162
+ end
163
+
164
+ # The architecture of the image.
165
+ # @return [String]
166
+ def architecture
167
+ data.architecture
168
+ end
169
+
170
+ # The root device type used by the AMI. The AMI can use an EBS volume or
171
+ # an instance store volume.
172
+ # @return [String]
173
+ def root_device_type
174
+ data.root_device_type
175
+ end
176
+
177
+ # The root device name (for example, `/dev/sda1` or `/dev/xvda`).
178
+ # @return [String]
179
+ def root_device_name
180
+ data.root_device_name
181
+ end
182
+
183
+ # Any block device mapping entries for the instance.
184
+ # @return [Array<Types::InstanceBlockDeviceMapping>]
185
+ def block_device_mappings
186
+ data.block_device_mappings
187
+ end
188
+
189
+ # The virtualization type of the instance.
190
+ # @return [String]
191
+ def virtualization_type
192
+ data.virtualization_type
193
+ end
194
+
195
+ # Indicates whether this is a Spot instance or a Scheduled Instance.
196
+ # @return [String]
197
+ def instance_lifecycle
198
+ data.instance_lifecycle
199
+ end
200
+
201
+ # If the request is a Spot instance request, the ID of the request.
202
+ # @return [String]
203
+ def spot_instance_request_id
204
+ data.spot_instance_request_id
205
+ end
206
+
207
+ # The idempotency token you provided when you launched the instance, if
208
+ # applicable.
209
+ # @return [String]
210
+ def client_token
211
+ data.client_token
212
+ end
213
+
214
+ # Any tags assigned to the instance.
215
+ # @return [Array<Types::Tag>]
216
+ def tags
217
+ data.tags
218
+ end
219
+
220
+ # One or more security groups for the instance.
221
+ # @return [Array<Types::GroupIdentifier>]
222
+ def security_groups
223
+ data.security_groups
224
+ end
225
+
226
+ # Specifies whether to enable an instance launched in a VPC to perform
227
+ # NAT. This controls whether source/destination checking is enabled on
228
+ # the instance. A value of `true` means checking is enabled, and `false`
229
+ # means checking is disabled. The value must be `false` for the instance
230
+ # to perform NAT. For more information, see [NAT Instances][1] in the
231
+ # *Amazon Virtual Private Cloud User Guide*.
232
+ #
233
+ #
234
+ #
235
+ # [1]: http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_NAT_Instance.html
236
+ # @return [Boolean]
237
+ def source_dest_check
238
+ data.source_dest_check
239
+ end
240
+
241
+ # The hypervisor type of the instance.
242
+ # @return [String]
243
+ def hypervisor
244
+ data.hypervisor
245
+ end
246
+
247
+ # The IAM instance profile associated with the instance, if applicable.
248
+ # @return [Types::IamInstanceProfile]
249
+ def iam_instance_profile
250
+ data.iam_instance_profile
251
+ end
252
+
253
+ # Indicates whether the instance is optimized for EBS I/O. This
254
+ # optimization provides dedicated throughput to Amazon EBS and an
255
+ # optimized configuration stack to provide optimal I/O performance. This
256
+ # optimization isn't available with all instance types. Additional
257
+ # usage charges apply when using an EBS Optimized instance.
258
+ # @return [Boolean]
259
+ def ebs_optimized
260
+ data.ebs_optimized
261
+ end
262
+
263
+ # Specifies whether enhanced networking with the Intel 82599 Virtual
264
+ # Function interface is enabled.
265
+ # @return [String]
266
+ def sriov_net_support
267
+ data.sriov_net_support
268
+ end
269
+
270
+ # Specifies whether enhanced networking with ENA is enabled.
271
+ # @return [Boolean]
272
+ def ena_support
273
+ data.ena_support
274
+ end
275
+
276
+ # @!endgroup
277
+
278
+ # @return [Client]
279
+ def client
280
+ @client
281
+ end
282
+
283
+ # Loads, or reloads {#data} for the current {Instance}.
284
+ # Returns `self` making it possible to chain methods.
285
+ #
286
+ # instance.reload.data
287
+ #
288
+ # @return [self]
289
+ def load
290
+ resp = @client.describe_instances(instance_ids: [@id])
291
+ @data = resp.reservations[0].instances[0]
292
+ self
293
+ end
294
+ alias :reload :load
295
+
296
+ # @return [Types::Instance]
297
+ # Returns the data for this {Instance}. Calls
298
+ # {Client#describe_instances} if {#data_loaded?} is `false`.
299
+ def data
300
+ load unless @data
301
+ @data
302
+ end
303
+
304
+ # @return [Boolean]
305
+ # Returns `true` if this resource is loaded. Accessing attributes or
306
+ # {#data} on an unloaded resource will trigger a call to {#load}.
307
+ def data_loaded?
308
+ !!@data
309
+ end
310
+
311
+ # @param [Hash] options ({})
312
+ # @return [Boolean]
313
+ # Returns `true` if the Instance exists.
314
+ def exists?(options = {})
315
+ begin
316
+ wait_until_exists(options.merge(max_attempts: 1))
317
+ true
318
+ rescue Aws::Waiters::Errors::UnexpectedError => e
319
+ raise e.error
320
+ rescue Aws::Waiters::Errors::WaiterFailed
321
+ false
322
+ end
323
+ end
324
+
325
+ # @param [Hash] options ({})
326
+ # @option options [Integer] :max_attempts (40)
327
+ # @option options [Float] :delay (5)
328
+ # @option options [Proc] :before_attempt
329
+ # @option options [Proc] :before_wait
330
+ # @return [Instance]
331
+ def wait_until_exists(options = {})
332
+ options, params = separate_params_and_options(options)
333
+ waiter = Waiters::InstanceExists.new(options)
334
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
335
+ resp = waiter.wait(params.merge(instance_ids: [@id]))
336
+ Instance.new({
337
+ id: @id,
338
+ data: resp.data.reservations[0].instances[0],
339
+ client: @client
340
+ })
341
+ end
342
+
343
+ # @param [Hash] options ({})
344
+ # @option options [Integer] :max_attempts (40)
345
+ # @option options [Float] :delay (15)
346
+ # @option options [Proc] :before_attempt
347
+ # @option options [Proc] :before_wait
348
+ # @return [Instance]
349
+ def wait_until_running(options = {})
350
+ options, params = separate_params_and_options(options)
351
+ waiter = Waiters::InstanceRunning.new(options)
352
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
353
+ resp = waiter.wait(params.merge(instance_ids: [@id]))
354
+ Instance.new({
355
+ id: @id,
356
+ data: resp.data.reservations[0].instances[0],
357
+ client: @client
358
+ })
359
+ end
360
+
361
+ # @param [Hash] options ({})
362
+ # @option options [Integer] :max_attempts (40)
363
+ # @option options [Float] :delay (15)
364
+ # @option options [Proc] :before_attempt
365
+ # @option options [Proc] :before_wait
366
+ # @return [Instance]
367
+ def wait_until_stopped(options = {})
368
+ options, params = separate_params_and_options(options)
369
+ waiter = Waiters::InstanceStopped.new(options)
370
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
371
+ resp = waiter.wait(params.merge(instance_ids: [@id]))
372
+ Instance.new({
373
+ id: @id,
374
+ data: resp.data.reservations[0].instances[0],
375
+ client: @client
376
+ })
377
+ end
378
+
379
+ # @param [Hash] options ({})
380
+ # @option options [Integer] :max_attempts (40)
381
+ # @option options [Float] :delay (15)
382
+ # @option options [Proc] :before_attempt
383
+ # @option options [Proc] :before_wait
384
+ # @return [Instance]
385
+ def wait_until_terminated(options = {})
386
+ options, params = separate_params_and_options(options)
387
+ waiter = Waiters::InstanceTerminated.new(options)
388
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
389
+ resp = waiter.wait(params.merge(instance_ids: [@id]))
390
+ Instance.new({
391
+ id: @id,
392
+ data: resp.data.reservations[0].instances[0],
393
+ client: @client
394
+ })
395
+ end
396
+
397
+ # @!group Actions
398
+
399
+ # @example Request syntax with placeholder values
400
+ #
401
+ # instance.attach_classic_link_vpc({
402
+ # dry_run: false,
403
+ # vpc_id: "String", # required
404
+ # groups: ["String"], # required
405
+ # })
406
+ # @param [Hash] options ({})
407
+ # @option options [Boolean] :dry_run
408
+ # Checks whether you have the required permissions for the action,
409
+ # without actually making the request, and provides an error response.
410
+ # If you have the required permissions, the error response is
411
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
412
+ # @option options [required, String] :vpc_id
413
+ # The ID of a ClassicLink-enabled VPC.
414
+ # @option options [required, Array<String>] :groups
415
+ # The ID of one or more of the VPC's security groups. You cannot
416
+ # specify security groups from a different VPC.
417
+ # @return [Types::AttachClassicLinkVpcResult]
418
+ def attach_classic_link_vpc(options = {})
419
+ options = options.merge(instance_id: @id)
420
+ resp = @client.attach_classic_link_vpc(options)
421
+ resp.data
422
+ end
423
+
424
+ # @example Request syntax with placeholder values
425
+ #
426
+ # instance.attach_volume({
427
+ # dry_run: false,
428
+ # volume_id: "String", # required
429
+ # device: "String", # required
430
+ # })
431
+ # @param [Hash] options ({})
432
+ # @option options [Boolean] :dry_run
433
+ # Checks whether you have the required permissions for the action,
434
+ # without actually making the request, and provides an error response.
435
+ # If you have the required permissions, the error response is
436
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
437
+ # @option options [required, String] :volume_id
438
+ # The ID of the EBS volume. The volume and instance must be within the
439
+ # same Availability Zone.
440
+ # @option options [required, String] :device
441
+ # The device name to expose to the instance (for example, `/dev/sdh` or
442
+ # `xvdh`).
443
+ # @return [Types::VolumeAttachment]
444
+ def attach_volume(options = {})
445
+ options = options.merge(instance_id: @id)
446
+ resp = @client.attach_volume(options)
447
+ resp.data
448
+ end
449
+
450
+ # @example Request syntax with placeholder values
451
+ #
452
+ # instance.console_output({
453
+ # dry_run: false,
454
+ # })
455
+ # @param [Hash] options ({})
456
+ # @option options [Boolean] :dry_run
457
+ # Checks whether you have the required permissions for the action,
458
+ # without actually making the request, and provides an error response.
459
+ # If you have the required permissions, the error response is
460
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
461
+ # @return [Types::GetConsoleOutputResult]
462
+ def console_output(options = {})
463
+ options = options.merge(instance_id: @id)
464
+ resp = @client.get_console_output(options)
465
+ resp.data
466
+ end
467
+
468
+ # @example Request syntax with placeholder values
469
+ #
470
+ # image = instance.create_image({
471
+ # dry_run: false,
472
+ # name: "String", # required
473
+ # description: "String",
474
+ # no_reboot: false,
475
+ # block_device_mappings: [
476
+ # {
477
+ # virtual_name: "String",
478
+ # device_name: "String",
479
+ # ebs: {
480
+ # snapshot_id: "String",
481
+ # volume_size: 1,
482
+ # delete_on_termination: false,
483
+ # volume_type: "standard", # accepts standard, io1, gp2, sc1, st1
484
+ # iops: 1,
485
+ # encrypted: false,
486
+ # },
487
+ # no_device: "String",
488
+ # },
489
+ # ],
490
+ # })
491
+ # @param [Hash] options ({})
492
+ # @option options [Boolean] :dry_run
493
+ # Checks whether you have the required permissions for the action,
494
+ # without actually making the request, and provides an error response.
495
+ # If you have the required permissions, the error response is
496
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
497
+ # @option options [required, String] :name
498
+ # A name for the new image.
499
+ #
500
+ # Constraints: 3-128 alphanumeric characters, parentheses (()), square
501
+ # brackets (\[\]), spaces ( ), periods (.), slashes (/), dashes (-),
502
+ # single quotes ('), at-signs (@), or underscores(\_)
503
+ # @option options [String] :description
504
+ # A description for the new image.
505
+ # @option options [Boolean] :no_reboot
506
+ # By default, Amazon EC2 attempts to shut down and reboot the instance
507
+ # before creating the image. If the 'No Reboot' option is set, Amazon
508
+ # EC2 doesn't shut down the instance before creating the image. When
509
+ # this option is used, file system integrity on the created image can't
510
+ # be guaranteed.
511
+ # @option options [Array<Types::BlockDeviceMapping>] :block_device_mappings
512
+ # Information about one or more block device mappings.
513
+ # @return [Image]
514
+ def create_image(options = {})
515
+ options = options.merge(instance_id: @id)
516
+ resp = @client.create_image(options)
517
+ Image.new(
518
+ id: resp.data.image_id,
519
+ client: @client
520
+ )
521
+ end
522
+
523
+ # @example Request syntax with placeholder values
524
+ #
525
+ # tag = instance.create_tags({
526
+ # dry_run: false,
527
+ # tags: [ # required
528
+ # {
529
+ # key: "String",
530
+ # value: "String",
531
+ # },
532
+ # ],
533
+ # })
534
+ # @param [Hash] options ({})
535
+ # @option options [Boolean] :dry_run
536
+ # Checks whether you have the required permissions for the action,
537
+ # without actually making the request, and provides an error response.
538
+ # If you have the required permissions, the error response is
539
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
540
+ # @option options [required, Array<Types::Tag>] :tags
541
+ # One or more tags. The `value` parameter is required, but if you don't
542
+ # want the tag to have a value, specify the parameter with no value, and
543
+ # we set the value to an empty string.
544
+ # @return [Tag::Collection]
545
+ def create_tags(options = {})
546
+ batch = []
547
+ options = Aws::Util.deep_merge(options, resources: [@id])
548
+ resp = @client.create_tags(options)
549
+ options[:tags].each do |t|
550
+ batch << Tag.new(
551
+ resource_id: @id,
552
+ key: t[:key],
553
+ value: t[:value],
554
+ client: @client
555
+ )
556
+ end
557
+ Tag::Collection.new([batch], size: batch.size)
558
+ end
559
+
560
+ # @example Request syntax with placeholder values
561
+ #
562
+ # instance.describe_attribute({
563
+ # dry_run: false,
564
+ # attribute: "instanceType", # required, accepts instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDeviceName, blockDeviceMapping, productCodes, sourceDestCheck, groupSet, ebsOptimized, sriovNetSupport, enaSupport
565
+ # })
566
+ # @param [Hash] options ({})
567
+ # @option options [Boolean] :dry_run
568
+ # Checks whether you have the required permissions for the action,
569
+ # without actually making the request, and provides an error response.
570
+ # If you have the required permissions, the error response is
571
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
572
+ # @option options [required, String] :attribute
573
+ # The instance attribute.
574
+ #
575
+ # Note: The `enaSupport` attribute is not supported at this time.
576
+ # @return [Types::InstanceAttribute]
577
+ def describe_attribute(options = {})
578
+ options = options.merge(instance_id: @id)
579
+ resp = @client.describe_instance_attribute(options)
580
+ resp.data
581
+ end
582
+
583
+ # @example Request syntax with placeholder values
584
+ #
585
+ # instance.detach_classic_link_vpc({
586
+ # dry_run: false,
587
+ # vpc_id: "String", # required
588
+ # })
589
+ # @param [Hash] options ({})
590
+ # @option options [Boolean] :dry_run
591
+ # Checks whether you have the required permissions for the action,
592
+ # without actually making the request, and provides an error response.
593
+ # If you have the required permissions, the error response is
594
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
595
+ # @option options [required, String] :vpc_id
596
+ # The ID of the VPC to which the instance is linked.
597
+ # @return [Types::DetachClassicLinkVpcResult]
598
+ def detach_classic_link_vpc(options = {})
599
+ options = options.merge(instance_id: @id)
600
+ resp = @client.detach_classic_link_vpc(options)
601
+ resp.data
602
+ end
603
+
604
+ # @example Request syntax with placeholder values
605
+ #
606
+ # instance.detach_volume({
607
+ # dry_run: false,
608
+ # volume_id: "String", # required
609
+ # device: "String",
610
+ # force: false,
611
+ # })
612
+ # @param [Hash] options ({})
613
+ # @option options [Boolean] :dry_run
614
+ # Checks whether you have the required permissions for the action,
615
+ # without actually making the request, and provides an error response.
616
+ # If you have the required permissions, the error response is
617
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
618
+ # @option options [required, String] :volume_id
619
+ # The ID of the volume.
620
+ # @option options [String] :device
621
+ # The device name.
622
+ # @option options [Boolean] :force
623
+ # Forces detachment if the previous detachment attempt did not occur
624
+ # cleanly (for example, logging into an instance, unmounting the volume,
625
+ # and detaching normally). This option can lead to data loss or a
626
+ # corrupted file system. Use this option only as a last resort to detach
627
+ # a volume from a failed instance. The instance won't have an
628
+ # opportunity to flush file system caches or file system metadata. If
629
+ # you use this option, you must perform file system check and repair
630
+ # procedures.
631
+ # @return [Types::VolumeAttachment]
632
+ def detach_volume(options = {})
633
+ options = options.merge(instance_id: @id)
634
+ resp = @client.detach_volume(options)
635
+ resp.data
636
+ end
637
+
638
+ # @example Request syntax with placeholder values
639
+ #
640
+ # instance.modify_attribute({
641
+ # dry_run: false,
642
+ # attribute: "instanceType", # accepts instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDeviceName, blockDeviceMapping, productCodes, sourceDestCheck, groupSet, ebsOptimized, sriovNetSupport, enaSupport
643
+ # value: "String",
644
+ # block_device_mappings: [
645
+ # {
646
+ # device_name: "String",
647
+ # ebs: {
648
+ # volume_id: "String",
649
+ # delete_on_termination: false,
650
+ # },
651
+ # virtual_name: "String",
652
+ # no_device: "String",
653
+ # },
654
+ # ],
655
+ # source_dest_check: {
656
+ # value: false,
657
+ # },
658
+ # disable_api_termination: {
659
+ # value: false,
660
+ # },
661
+ # instance_type: "value", # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
662
+ # kernel: "value", # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
663
+ # ramdisk: "value", # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
664
+ # user_data: {
665
+ # value: "data",
666
+ # },
667
+ # instance_initiated_shutdown_behavior: "value", # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
668
+ # groups: ["String"],
669
+ # ebs_optimized: {
670
+ # value: false,
671
+ # },
672
+ # sriov_net_support: "value", # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
673
+ # ena_support: {
674
+ # value: false,
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 [String] :attribute
684
+ # The name of the attribute.
685
+ # @option options [String] :value
686
+ # A new value for the attribute. Use only with the `kernel`, `ramdisk`,
687
+ # `userData`, `disableApiTermination`, or
688
+ # `instanceInitiatedShutdownBehavior` attribute.
689
+ # @option options [Array<Types::InstanceBlockDeviceMappingSpecification>] :block_device_mappings
690
+ # Modifies the `DeleteOnTermination` attribute for volumes that are
691
+ # currently attached. The volume must be owned by the caller. If no
692
+ # value is specified for `DeleteOnTermination`, the default is `true`
693
+ # and the volume is deleted when the instance is terminated.
694
+ #
695
+ # To add instance store volumes to an Amazon EBS-backed instance, you
696
+ # must add them when you launch the instance. For more information, see
697
+ # [Updating the Block Device Mapping when Launching an Instance][1] in
698
+ # the *Amazon Elastic Compute Cloud User Guide*.
699
+ #
700
+ #
701
+ #
702
+ # [1]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html#Using_OverridingAMIBDM
703
+ # @option options [Types::AttributeBooleanValue] :source_dest_check
704
+ # Specifies whether source/destination checking is enabled. A value of
705
+ # `true` means that checking is enabled, and `false` means checking is
706
+ # disabled. This value must be `false` for a NAT instance to perform
707
+ # NAT.
708
+ # @option options [Types::AttributeBooleanValue] :disable_api_termination
709
+ # If the value is `true`, you can't terminate the instance using the
710
+ # Amazon EC2 console, CLI, or API; otherwise, you can. You cannot use
711
+ # this paramater for Spot Instances.
712
+ # @option options [Types::AttributeValue] :instance_type
713
+ # Changes the instance type to the specified value. For more
714
+ # information, see [Instance Types][1]. If the instance type is not
715
+ # valid, the error returned is `InvalidInstanceAttributeValue`.
716
+ #
717
+ #
718
+ #
719
+ # [1]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
720
+ # @option options [Types::AttributeValue] :kernel
721
+ # Changes the instance's kernel to the specified value. We recommend
722
+ # that you use PV-GRUB instead of kernels and RAM disks. For more
723
+ # information, see [PV-GRUB][1].
724
+ #
725
+ #
726
+ #
727
+ # [1]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UserProvidedKernels.html
728
+ # @option options [Types::AttributeValue] :ramdisk
729
+ # Changes the instance's RAM disk to the specified value. We recommend
730
+ # that you use PV-GRUB instead of kernels and RAM disks. For more
731
+ # information, see [PV-GRUB][1].
732
+ #
733
+ #
734
+ #
735
+ # [1]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UserProvidedKernels.html
736
+ # @option options [Types::BlobAttributeValue] :user_data
737
+ # Changes the instance's user data to the specified value. If you are
738
+ # using an AWS SDK or command line tool, Base64-encoding is performed
739
+ # for you, and you can load the text from a file. Otherwise, you must
740
+ # provide Base64-encoded text.
741
+ # @option options [Types::AttributeValue] :instance_initiated_shutdown_behavior
742
+ # Specifies whether an instance stops or terminates when you initiate
743
+ # shutdown from the instance (using the operating system command for
744
+ # system shutdown).
745
+ # @option options [Array<String>] :groups
746
+ # \[EC2-VPC\] Changes the security groups of the instance. You must
747
+ # specify at least one security group, even if it's just the default
748
+ # security group for the VPC. You must specify the security group ID,
749
+ # not the security group name.
750
+ # @option options [Types::AttributeBooleanValue] :ebs_optimized
751
+ # Specifies whether the instance is optimized for EBS I/O. This
752
+ # optimization provides dedicated throughput to Amazon EBS and an
753
+ # optimized configuration stack to provide optimal EBS I/O performance.
754
+ # This optimization isn't available with all instance types. Additional
755
+ # usage charges apply when using an EBS Optimized instance.
756
+ # @option options [Types::AttributeValue] :sriov_net_support
757
+ # Set to `simple` to enable enhanced networking with the Intel 82599
758
+ # Virtual Function interface for the instance.
759
+ #
760
+ # There is no way to disable enhanced networking with the Intel 82599
761
+ # Virtual Function interface at this time.
762
+ #
763
+ # This option is supported only for HVM instances. Specifying this
764
+ # option with a PV instance can make it unreachable.
765
+ # @option options [Types::AttributeBooleanValue] :ena_support
766
+ # Set to `true` to enable enhanced networking with ENA for the instance.
767
+ #
768
+ # This option is supported only for HVM instances. Specifying this
769
+ # option with a PV instance can make it unreachable.
770
+ # @return [EmptyStructure]
771
+ def modify_attribute(options = {})
772
+ options = options.merge(instance_id: @id)
773
+ resp = @client.modify_instance_attribute(options)
774
+ resp.data
775
+ end
776
+
777
+ # @example Request syntax with placeholder values
778
+ #
779
+ # instance.monitor({
780
+ # dry_run: false,
781
+ # })
782
+ # @param [Hash] options ({})
783
+ # @option options [Boolean] :dry_run
784
+ # Checks whether you have the required permissions for the action,
785
+ # without actually making the request, and provides an error response.
786
+ # If you have the required permissions, the error response is
787
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
788
+ # @return [Types::MonitorInstancesResult]
789
+ def monitor(options = {})
790
+ options = Aws::Util.deep_merge(options, instance_ids: [@id])
791
+ resp = @client.monitor_instances(options)
792
+ resp.data
793
+ end
794
+
795
+ # @example Request syntax with placeholder values
796
+ #
797
+ # instance.password_data({
798
+ # dry_run: false,
799
+ # })
800
+ # @param [Hash] options ({})
801
+ # @option options [Boolean] :dry_run
802
+ # Checks whether you have the required permissions for the action,
803
+ # without actually making the request, and provides an error response.
804
+ # If you have the required permissions, the error response is
805
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
806
+ # @return [Types::GetPasswordDataResult]
807
+ def password_data(options = {})
808
+ options = options.merge(instance_id: @id)
809
+ resp = @client.get_password_data(options)
810
+ resp.data
811
+ end
812
+
813
+ # @example Request syntax with placeholder values
814
+ #
815
+ # instance.reboot({
816
+ # dry_run: false,
817
+ # })
818
+ # @param [Hash] options ({})
819
+ # @option options [Boolean] :dry_run
820
+ # Checks whether you have the required permissions for the action,
821
+ # without actually making the request, and provides an error response.
822
+ # If you have the required permissions, the error response is
823
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
824
+ # @return [EmptyStructure]
825
+ def reboot(options = {})
826
+ options = Aws::Util.deep_merge(options, instance_ids: [@id])
827
+ resp = @client.reboot_instances(options)
828
+ resp.data
829
+ end
830
+
831
+ # @example Request syntax with placeholder values
832
+ #
833
+ # instance.report_status({
834
+ # dry_run: false,
835
+ # status: "ok", # required, accepts ok, impaired
836
+ # start_time: Time.now,
837
+ # end_time: Time.now,
838
+ # reason_codes: ["instance-stuck-in-state"], # required, accepts instance-stuck-in-state, unresponsive, not-accepting-credentials, password-not-available, performance-network, performance-instance-store, performance-ebs-volume, performance-other, other
839
+ # description: "String",
840
+ # })
841
+ # @param [Hash] options ({})
842
+ # @option options [Boolean] :dry_run
843
+ # Checks whether you have the required permissions for the action,
844
+ # without actually making the request, and provides an error response.
845
+ # If you have the required permissions, the error response is
846
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
847
+ # @option options [required, String] :status
848
+ # The status of all instances listed.
849
+ # @option options [Time,DateTime,Date,Integer,String] :start_time
850
+ # The time at which the reported instance health state began.
851
+ # @option options [Time,DateTime,Date,Integer,String] :end_time
852
+ # The time at which the reported instance health state ended.
853
+ # @option options [required, Array<String>] :reason_codes
854
+ # One or more reason codes that describes the health state of your
855
+ # instance.
856
+ #
857
+ # * `instance-stuck-in-state`\: My instance is stuck in a state.
858
+ #
859
+ # * `unresponsive`\: My instance is unresponsive.
860
+ #
861
+ # * `not-accepting-credentials`\: My instance is not accepting my
862
+ # credentials.
863
+ #
864
+ # * `password-not-available`\: A password is not available for my
865
+ # instance.
866
+ #
867
+ # * `performance-network`\: My instance is experiencing performance
868
+ # problems which I believe are network related.
869
+ #
870
+ # * `performance-instance-store`\: My instance is experiencing
871
+ # performance problems which I believe are related to the instance
872
+ # stores.
873
+ #
874
+ # * `performance-ebs-volume`\: My instance is experiencing performance
875
+ # problems which I believe are related to an EBS volume.
876
+ #
877
+ # * `performance-other`\: My instance is experiencing performance
878
+ # problems.
879
+ #
880
+ # * `other`\: \[explain using the description parameter\]
881
+ # @option options [String] :description
882
+ # Descriptive text about the health state of your instance.
883
+ # @return [EmptyStructure]
884
+ def report_status(options = {})
885
+ options = Aws::Util.deep_merge(options, instances: [@id])
886
+ resp = @client.report_instance_status(options)
887
+ resp.data
888
+ end
889
+
890
+ # @example Request syntax with placeholder values
891
+ #
892
+ # instance.reset_attribute({
893
+ # dry_run: false,
894
+ # attribute: "instanceType", # required, accepts instanceType, kernel, ramdisk, userData, disableApiTermination, instanceInitiatedShutdownBehavior, rootDeviceName, blockDeviceMapping, productCodes, sourceDestCheck, groupSet, ebsOptimized, sriovNetSupport, enaSupport
895
+ # })
896
+ # @param [Hash] options ({})
897
+ # @option options [Boolean] :dry_run
898
+ # Checks whether you have the required permissions for the action,
899
+ # without actually making the request, and provides an error response.
900
+ # If you have the required permissions, the error response is
901
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
902
+ # @option options [required, String] :attribute
903
+ # The attribute to reset.
904
+ #
905
+ # You can only reset the following attributes: `kernel` \| `ramdisk` \|
906
+ # `sourceDestCheck`. To change an instance attribute, use
907
+ # ModifyInstanceAttribute.
908
+ # @return [EmptyStructure]
909
+ def reset_attribute(options = {})
910
+ options = options.merge(instance_id: @id)
911
+ resp = @client.reset_instance_attribute(options)
912
+ resp.data
913
+ end
914
+
915
+ # @example Request syntax with placeholder values
916
+ #
917
+ # instance.reset_kernel({
918
+ # dry_run: false,
919
+ # })
920
+ # @param [Hash] options ({})
921
+ # @option options [Boolean] :dry_run
922
+ # Checks whether you have the required permissions for the action,
923
+ # without actually making the request, and provides an error response.
924
+ # If you have the required permissions, the error response is
925
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
926
+ # @return [EmptyStructure]
927
+ def reset_kernel(options = {})
928
+ options = options.merge(
929
+ instance_id: @id,
930
+ attribute: "kernel"
931
+ )
932
+ resp = @client.reset_instance_attribute(options)
933
+ resp.data
934
+ end
935
+
936
+ # @example Request syntax with placeholder values
937
+ #
938
+ # instance.reset_ramdisk({
939
+ # dry_run: false,
940
+ # })
941
+ # @param [Hash] options ({})
942
+ # @option options [Boolean] :dry_run
943
+ # Checks whether you have the required permissions for the action,
944
+ # without actually making the request, and provides an error response.
945
+ # If you have the required permissions, the error response is
946
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
947
+ # @return [EmptyStructure]
948
+ def reset_ramdisk(options = {})
949
+ options = options.merge(
950
+ instance_id: @id,
951
+ attribute: "ramdisk"
952
+ )
953
+ resp = @client.reset_instance_attribute(options)
954
+ resp.data
955
+ end
956
+
957
+ # @example Request syntax with placeholder values
958
+ #
959
+ # instance.reset_source_dest_check({
960
+ # dry_run: false,
961
+ # })
962
+ # @param [Hash] options ({})
963
+ # @option options [Boolean] :dry_run
964
+ # Checks whether you have the required permissions for the action,
965
+ # without actually making the request, and provides an error response.
966
+ # If you have the required permissions, the error response is
967
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
968
+ # @return [EmptyStructure]
969
+ def reset_source_dest_check(options = {})
970
+ options = options.merge(
971
+ instance_id: @id,
972
+ attribute: "sourceDestCheck"
973
+ )
974
+ resp = @client.reset_instance_attribute(options)
975
+ resp.data
976
+ end
977
+
978
+ # @example Request syntax with placeholder values
979
+ #
980
+ # instance.start({
981
+ # additional_info: "String",
982
+ # dry_run: false,
983
+ # })
984
+ # @param [Hash] options ({})
985
+ # @option options [String] :additional_info
986
+ # Reserved.
987
+ # @option options [Boolean] :dry_run
988
+ # Checks whether you have the required permissions for the action,
989
+ # without actually making the request, and provides an error response.
990
+ # If you have the required permissions, the error response is
991
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
992
+ # @return [Types::StartInstancesResult]
993
+ def start(options = {})
994
+ options = Aws::Util.deep_merge(options, instance_ids: [@id])
995
+ resp = @client.start_instances(options)
996
+ resp.data
997
+ end
998
+
999
+ # @example Request syntax with placeholder values
1000
+ #
1001
+ # instance.stop({
1002
+ # dry_run: false,
1003
+ # force: false,
1004
+ # })
1005
+ # @param [Hash] options ({})
1006
+ # @option options [Boolean] :dry_run
1007
+ # Checks whether you have the required permissions for the action,
1008
+ # without actually making the request, and provides an error response.
1009
+ # If you have the required permissions, the error response is
1010
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1011
+ # @option options [Boolean] :force
1012
+ # Forces the instances to stop. The instances do not have an opportunity
1013
+ # to flush file system caches or file system metadata. If you use this
1014
+ # option, you must perform file system check and repair procedures. This
1015
+ # option is not recommended for Windows instances.
1016
+ #
1017
+ # Default: `false`
1018
+ # @return [Types::StopInstancesResult]
1019
+ def stop(options = {})
1020
+ options = Aws::Util.deep_merge(options, instance_ids: [@id])
1021
+ resp = @client.stop_instances(options)
1022
+ resp.data
1023
+ end
1024
+
1025
+ # @example Request syntax with placeholder values
1026
+ #
1027
+ # instance.terminate({
1028
+ # dry_run: false,
1029
+ # })
1030
+ # @param [Hash] options ({})
1031
+ # @option options [Boolean] :dry_run
1032
+ # Checks whether you have the required permissions for the action,
1033
+ # without actually making the request, and provides an error response.
1034
+ # If you have the required permissions, the error response is
1035
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1036
+ # @return [Types::TerminateInstancesResult]
1037
+ def terminate(options = {})
1038
+ options = Aws::Util.deep_merge(options, instance_ids: [@id])
1039
+ resp = @client.terminate_instances(options)
1040
+ resp.data
1041
+ end
1042
+
1043
+ # @example Request syntax with placeholder values
1044
+ #
1045
+ # instance.unmonitor({
1046
+ # dry_run: false,
1047
+ # })
1048
+ # @param [Hash] options ({})
1049
+ # @option options [Boolean] :dry_run
1050
+ # Checks whether you have the required permissions for the action,
1051
+ # without actually making the request, and provides an error response.
1052
+ # If you have the required permissions, the error response is
1053
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1054
+ # @return [Types::UnmonitorInstancesResult]
1055
+ def unmonitor(options = {})
1056
+ options = Aws::Util.deep_merge(options, instance_ids: [@id])
1057
+ resp = @client.unmonitor_instances(options)
1058
+ resp.data
1059
+ end
1060
+
1061
+ # @!group Associations
1062
+
1063
+ # @return [ClassicAddress, nil]
1064
+ def classic_address
1065
+ if data.public_ip_address
1066
+ ClassicAddress.new(
1067
+ public_ip: data.public_ip_address,
1068
+ client: @client
1069
+ )
1070
+ else
1071
+ nil
1072
+ end
1073
+ end
1074
+
1075
+ # @return [Image, nil]
1076
+ def image
1077
+ if data.image_id
1078
+ Image.new(
1079
+ id: data.image_id,
1080
+ client: @client
1081
+ )
1082
+ else
1083
+ nil
1084
+ end
1085
+ end
1086
+
1087
+ # @return [KeyPairInfo, nil]
1088
+ def key_pair
1089
+ if data.key_name
1090
+ KeyPairInfo.new(
1091
+ name: data.key_name,
1092
+ client: @client
1093
+ )
1094
+ else
1095
+ nil
1096
+ end
1097
+ end
1098
+
1099
+ # @return [NetworkInterface::Collection]
1100
+ def network_interfaces
1101
+ batch = []
1102
+ data.network_interfaces.each do |n|
1103
+ batch << NetworkInterface.new(
1104
+ id: n.network_interface_id,
1105
+ data: n,
1106
+ client: @client
1107
+ )
1108
+ end
1109
+ NetworkInterface::Collection.new([batch], size: batch.size)
1110
+ end
1111
+
1112
+ # @return [PlacementGroup, nil]
1113
+ def placement_group
1114
+ if data.placement.group_name
1115
+ PlacementGroup.new(
1116
+ name: data.placement.group_name,
1117
+ client: @client
1118
+ )
1119
+ else
1120
+ nil
1121
+ end
1122
+ end
1123
+
1124
+ # @return [Subnet, nil]
1125
+ def subnet
1126
+ if data.subnet_id
1127
+ Subnet.new(
1128
+ id: data.subnet_id,
1129
+ client: @client
1130
+ )
1131
+ else
1132
+ nil
1133
+ end
1134
+ end
1135
+
1136
+ # @example Request syntax with placeholder values
1137
+ #
1138
+ # volumes = instance.volumes({
1139
+ # dry_run: false,
1140
+ # volume_ids: ["String"],
1141
+ # filters: [
1142
+ # {
1143
+ # name: "String",
1144
+ # values: ["String"],
1145
+ # },
1146
+ # ],
1147
+ # })
1148
+ # @param [Hash] options ({})
1149
+ # @option options [Boolean] :dry_run
1150
+ # Checks whether you have the required permissions for the action,
1151
+ # without actually making the request, and provides an error response.
1152
+ # If you have the required permissions, the error response is
1153
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1154
+ # @option options [Array<String>] :volume_ids
1155
+ # One or more volume IDs.
1156
+ # @option options [Array<Types::Filter>] :filters
1157
+ # One or more filters.
1158
+ #
1159
+ # * `attachment.attach-time` - The time stamp when the attachment
1160
+ # initiated.
1161
+ #
1162
+ # * `attachment.delete-on-termination` - Whether the volume is deleted
1163
+ # on instance termination.
1164
+ #
1165
+ # * `attachment.device` - The device name that is exposed to the
1166
+ # instance (for example, `/dev/sda1`).
1167
+ #
1168
+ # * `attachment.instance-id` - The ID of the instance the volume is
1169
+ # attached to.
1170
+ #
1171
+ # * `attachment.status` - The attachment state (`attaching` \|
1172
+ # `attached` \| `detaching` \| `detached`).
1173
+ #
1174
+ # * `availability-zone` - The Availability Zone in which the volume was
1175
+ # created.
1176
+ #
1177
+ # * `create-time` - The time stamp when the volume was created.
1178
+ #
1179
+ # * `encrypted` - The encryption status of the volume.
1180
+ #
1181
+ # * `size` - The size of the volume, in GiB.
1182
+ #
1183
+ # * `snapshot-id` - The snapshot from which the volume was created.
1184
+ #
1185
+ # * `status` - The status of the volume (`creating` \| `available` \|
1186
+ # `in-use` \| `deleting` \| `deleted` \| `error`).
1187
+ #
1188
+ # * `tag`\:*key*=*value* - The key/value combination of a tag assigned
1189
+ # to the resource.
1190
+ #
1191
+ # * `tag-key` - The key of a tag assigned to the resource. This filter
1192
+ # is independent of the `tag-value` filter. For example, if you use
1193
+ # both the filter "tag-key=Purpose" and the filter "tag-value=X",
1194
+ # you get any resources assigned both the tag key Purpose (regardless
1195
+ # of what the tag's value is), and the tag value X (regardless of
1196
+ # what the tag's key is). If you want to list only resources where
1197
+ # Purpose is X, see the `tag`\:*key*=*value* filter.
1198
+ #
1199
+ # * `tag-value` - The value of a tag assigned to the resource. This
1200
+ # filter is independent of the `tag-key` filter.
1201
+ #
1202
+ # * `volume-id` - The volume ID.
1203
+ #
1204
+ # * `volume-type` - The Amazon EBS volume type. This can be `gp2` for
1205
+ # General Purpose SSD, `io1` for Provisioned IOPS SSD, `st1` for
1206
+ # Throughput Optimized HDD, `sc1` for Cold HDD, or `standard` for
1207
+ # Magnetic volumes.
1208
+ # @return [Volume::Collection]
1209
+ def volumes(options = {})
1210
+ batches = Enumerator.new do |y|
1211
+ options = Aws::Util.deep_merge(options, filters: [{
1212
+ name: "attachment.instance-id",
1213
+ values: [@id]
1214
+ }])
1215
+ resp = @client.describe_volumes(options)
1216
+ resp.each_page do |page|
1217
+ batch = []
1218
+ page.data.volumes.each do |v|
1219
+ batch << Volume.new(
1220
+ id: v.volume_id,
1221
+ data: v,
1222
+ client: @client
1223
+ )
1224
+ end
1225
+ y.yield(batch)
1226
+ end
1227
+ end
1228
+ Volume::Collection.new(batches)
1229
+ end
1230
+
1231
+ # @return [Vpc, nil]
1232
+ def vpc
1233
+ if data.vpc_id
1234
+ Vpc.new(
1235
+ id: data.vpc_id,
1236
+ client: @client
1237
+ )
1238
+ else
1239
+ nil
1240
+ end
1241
+ end
1242
+
1243
+ # @example Request syntax with placeholder values
1244
+ #
1245
+ # vpcaddresses = instance.vpc_addresses({
1246
+ # dry_run: false,
1247
+ # public_ips: ["String"],
1248
+ # filters: [
1249
+ # {
1250
+ # name: "String",
1251
+ # values: ["String"],
1252
+ # },
1253
+ # ],
1254
+ # allocation_ids: ["String"],
1255
+ # })
1256
+ # @param [Hash] options ({})
1257
+ # @option options [Boolean] :dry_run
1258
+ # Checks whether you have the required permissions for the action,
1259
+ # without actually making the request, and provides an error response.
1260
+ # If you have the required permissions, the error response is
1261
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1262
+ # @option options [Array<String>] :public_ips
1263
+ # \[EC2-Classic\] One or more Elastic IP addresses.
1264
+ #
1265
+ # Default: Describes all your Elastic IP addresses.
1266
+ # @option options [Array<Types::Filter>] :filters
1267
+ # One or more filters. Filter names and values are case-sensitive.
1268
+ #
1269
+ # * `allocation-id` - \[EC2-VPC\] The allocation ID for the address.
1270
+ #
1271
+ # * `association-id` - \[EC2-VPC\] The association ID for the address.
1272
+ #
1273
+ # * `domain` - Indicates whether the address is for use in EC2-Classic
1274
+ # (`standard`) or in a VPC (`vpc`).
1275
+ #
1276
+ # * `instance-id` - The ID of the instance the address is associated
1277
+ # with, if any.
1278
+ #
1279
+ # * `network-interface-id` - \[EC2-VPC\] The ID of the network interface
1280
+ # that the address is associated with, if any.
1281
+ #
1282
+ # * `network-interface-owner-id` - The AWS account ID of the owner.
1283
+ #
1284
+ # * `private-ip-address` - \[EC2-VPC\] The private IP address associated
1285
+ # with the Elastic IP address.
1286
+ #
1287
+ # * `public-ip` - The Elastic IP address.
1288
+ # @option options [Array<String>] :allocation_ids
1289
+ # \[EC2-VPC\] One or more allocation IDs.
1290
+ #
1291
+ # Default: Describes all your Elastic IP addresses.
1292
+ # @return [VpcAddress::Collection]
1293
+ def vpc_addresses(options = {})
1294
+ batches = Enumerator.new do |y|
1295
+ batch = []
1296
+ options = Aws::Util.deep_merge(options, filters: [{
1297
+ name: "instance-id",
1298
+ values: [@id]
1299
+ }])
1300
+ resp = @client.describe_addresses(options)
1301
+ resp.data.addresses.each do |a|
1302
+ batch << VpcAddress.new(
1303
+ allocation_id: a.allocation_id,
1304
+ data: a,
1305
+ client: @client
1306
+ )
1307
+ end
1308
+ y.yield(batch)
1309
+ end
1310
+ VpcAddress::Collection.new(batches)
1311
+ end
1312
+
1313
+ # @deprecated
1314
+ # @api private
1315
+ def identifiers
1316
+ { id: @id }
1317
+ end
1318
+ deprecated(:identifiers)
1319
+
1320
+ private
1321
+
1322
+ def extract_id(args, options)
1323
+ value = args[0] || options.delete(:id)
1324
+ case value
1325
+ when String then value
1326
+ when nil then raise ArgumentError, "missing required option :id"
1327
+ else
1328
+ msg = "expected :id to be a String, got #{value.class}"
1329
+ raise ArgumentError, msg
1330
+ end
1331
+ end
1332
+
1333
+ def yield_waiter_and_warn(waiter, &block)
1334
+ if !@waiter_block_warned
1335
+ msg = "pass options to configure the waiter; "
1336
+ msg << "yielding the waiter is deprecated"
1337
+ warn(msg)
1338
+ @waiter_block_warned = true
1339
+ end
1340
+ yield(waiter.waiter)
1341
+ end
1342
+
1343
+ def separate_params_and_options(options)
1344
+ opts = Set.new([:client, :max_attempts, :delay, :before_attempt, :before_wait])
1345
+ waiter_opts = {}
1346
+ waiter_params = {}
1347
+ options.each_pair do |key, value|
1348
+ if opts.include?(key)
1349
+ waiter_opts[key] = value
1350
+ else
1351
+ waiter_params[key] = value
1352
+ end
1353
+ end
1354
+ waiter_opts[:client] ||= @client
1355
+ [waiter_opts, waiter_params]
1356
+ end
1357
+
1358
+ class Collection < Aws::Resources::Collection
1359
+
1360
+ # @!group Batch Actions
1361
+
1362
+ # @example Request syntax with placeholder values
1363
+ #
1364
+ # instance.batch_create_tags({
1365
+ # dry_run: false,
1366
+ # tags: [ # required
1367
+ # {
1368
+ # key: "String",
1369
+ # value: "String",
1370
+ # },
1371
+ # ],
1372
+ # })
1373
+ # @param options ({})
1374
+ # @option options [Boolean] :dry_run
1375
+ # Checks whether you have the required permissions for the action,
1376
+ # without actually making the request, and provides an error response.
1377
+ # If you have the required permissions, the error response is
1378
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1379
+ # @option options [required, Array<Types::Tag>] :tags
1380
+ # One or more tags. The `value` parameter is required, but if you don't
1381
+ # want the tag to have a value, specify the parameter with no value, and
1382
+ # we set the value to an empty string.
1383
+ # @return [void]
1384
+ def batch_create_tags(options = {})
1385
+ batch_enum.each do |batch|
1386
+ params = Aws::Util.copy_hash(options)
1387
+ params[:resources] ||= []
1388
+ batch.each do |item|
1389
+ params[:resources] << {
1390
+ id: item.id
1391
+ }
1392
+ end
1393
+ batch[0].client.create_tags(params)
1394
+ end
1395
+ nil
1396
+ end
1397
+
1398
+ # @example Request syntax with placeholder values
1399
+ #
1400
+ # instance.batch_monitor({
1401
+ # dry_run: false,
1402
+ # })
1403
+ # @param options ({})
1404
+ # @option options [Boolean] :dry_run
1405
+ # Checks whether you have the required permissions for the action,
1406
+ # without actually making the request, and provides an error response.
1407
+ # If you have the required permissions, the error response is
1408
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1409
+ # @return [void]
1410
+ def batch_monitor(options = {})
1411
+ batch_enum.each do |batch|
1412
+ params = Aws::Util.copy_hash(options)
1413
+ params[:instance_ids] ||= []
1414
+ batch.each do |item|
1415
+ params[:instance_ids] << {
1416
+ id: item.id
1417
+ }
1418
+ end
1419
+ batch[0].client.monitor_instances(params)
1420
+ end
1421
+ nil
1422
+ end
1423
+
1424
+ # @example Request syntax with placeholder values
1425
+ #
1426
+ # instance.batch_reboot({
1427
+ # dry_run: false,
1428
+ # })
1429
+ # @param options ({})
1430
+ # @option options [Boolean] :dry_run
1431
+ # Checks whether you have the required permissions for the action,
1432
+ # without actually making the request, and provides an error response.
1433
+ # If you have the required permissions, the error response is
1434
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1435
+ # @return [void]
1436
+ def batch_reboot(options = {})
1437
+ batch_enum.each do |batch|
1438
+ params = Aws::Util.copy_hash(options)
1439
+ params[:instance_ids] ||= []
1440
+ batch.each do |item|
1441
+ params[:instance_ids] << {
1442
+ id: item.id
1443
+ }
1444
+ end
1445
+ batch[0].client.reboot_instances(params)
1446
+ end
1447
+ nil
1448
+ end
1449
+
1450
+ # @example Request syntax with placeholder values
1451
+ #
1452
+ # instance.batch_start({
1453
+ # additional_info: "String",
1454
+ # dry_run: false,
1455
+ # })
1456
+ # @param options ({})
1457
+ # @option options [String] :additional_info
1458
+ # Reserved.
1459
+ # @option options [Boolean] :dry_run
1460
+ # Checks whether you have the required permissions for the action,
1461
+ # without actually making the request, and provides an error response.
1462
+ # If you have the required permissions, the error response is
1463
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1464
+ # @return [void]
1465
+ def batch_start(options = {})
1466
+ batch_enum.each do |batch|
1467
+ params = Aws::Util.copy_hash(options)
1468
+ params[:instance_ids] ||= []
1469
+ batch.each do |item|
1470
+ params[:instance_ids] << {
1471
+ id: item.id
1472
+ }
1473
+ end
1474
+ batch[0].client.start_instances(params)
1475
+ end
1476
+ nil
1477
+ end
1478
+
1479
+ # @example Request syntax with placeholder values
1480
+ #
1481
+ # instance.batch_stop({
1482
+ # dry_run: false,
1483
+ # force: false,
1484
+ # })
1485
+ # @param options ({})
1486
+ # @option options [Boolean] :dry_run
1487
+ # Checks whether you have the required permissions for the action,
1488
+ # without actually making the request, and provides an error response.
1489
+ # If you have the required permissions, the error response is
1490
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1491
+ # @option options [Boolean] :force
1492
+ # Forces the instances to stop. The instances do not have an opportunity
1493
+ # to flush file system caches or file system metadata. If you use this
1494
+ # option, you must perform file system check and repair procedures. This
1495
+ # option is not recommended for Windows instances.
1496
+ #
1497
+ # Default: `false`
1498
+ # @return [void]
1499
+ def batch_stop(options = {})
1500
+ batch_enum.each do |batch|
1501
+ params = Aws::Util.copy_hash(options)
1502
+ params[:instance_ids] ||= []
1503
+ batch.each do |item|
1504
+ params[:instance_ids] << {
1505
+ id: item.id
1506
+ }
1507
+ end
1508
+ batch[0].client.stop_instances(params)
1509
+ end
1510
+ nil
1511
+ end
1512
+
1513
+ # @example Request syntax with placeholder values
1514
+ #
1515
+ # instance.batch_terminate!({
1516
+ # dry_run: false,
1517
+ # })
1518
+ # @param options ({})
1519
+ # @option options [Boolean] :dry_run
1520
+ # Checks whether you have the required permissions for the action,
1521
+ # without actually making the request, and provides an error response.
1522
+ # If you have the required permissions, the error response is
1523
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1524
+ # @return [void]
1525
+ def batch_terminate!(options = {})
1526
+ batch_enum.each do |batch|
1527
+ params = Aws::Util.copy_hash(options)
1528
+ params[:instance_ids] ||= []
1529
+ batch.each do |item|
1530
+ params[:instance_ids] << {
1531
+ id: item.id
1532
+ }
1533
+ end
1534
+ batch[0].client.terminate_instances(params)
1535
+ end
1536
+ nil
1537
+ end
1538
+
1539
+ # @example Request syntax with placeholder values
1540
+ #
1541
+ # instance.batch_unmonitor({
1542
+ # dry_run: false,
1543
+ # })
1544
+ # @param options ({})
1545
+ # @option options [Boolean] :dry_run
1546
+ # Checks whether you have the required permissions for the action,
1547
+ # without actually making the request, and provides an error response.
1548
+ # If you have the required permissions, the error response is
1549
+ # `DryRunOperation`. Otherwise, it is `UnauthorizedOperation`.
1550
+ # @return [void]
1551
+ def batch_unmonitor(options = {})
1552
+ batch_enum.each do |batch|
1553
+ params = Aws::Util.copy_hash(options)
1554
+ params[:instance_ids] ||= []
1555
+ batch.each do |item|
1556
+ params[:instance_ids] << {
1557
+ id: item.id
1558
+ }
1559
+ end
1560
+ batch[0].client.unmonitor_instances(params)
1561
+ end
1562
+ nil
1563
+ end
1564
+
1565
+ # @!endgroup
1566
+
1567
+ end
1568
+ end
1569
+ end
1570
+ end