aws-sdk-ec2 1.0.0.rc2 → 1.0.0.rc3

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