aws_sdk_ec2/operation/terminate_instances/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::terminate_instances::_terminate_instances_output::TerminateInstancesOutputBuilder;
3
4pub use crate::operation::terminate_instances::_terminate_instances_input::TerminateInstancesInputBuilder;
5
6impl crate::operation::terminate_instances::builders::TerminateInstancesInputBuilder {
7 /// Sends a request with this input using the given client.
8 pub async fn send_with(
9 self,
10 client: &crate::Client,
11 ) -> ::std::result::Result<
12 crate::operation::terminate_instances::TerminateInstancesOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::terminate_instances::TerminateInstancesError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.terminate_instances();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `TerminateInstances`.
24///
25/// <p>Terminates (deletes) the specified instances. This operation is <a href="https://docs.aws.amazon.com/ec2/latest/devguide/ec2-api-idempotency.html">idempotent</a>; if you terminate an instance more than once, each call succeeds.</p><important>
26/// <p><b>Terminating an instance is permanent and irreversible.</b></p>
27/// <p>After you terminate an instance, you can no longer connect to it, and it can't be recovered. All attached Amazon EBS volumes that are configured to be deleted on termination are also permanently deleted and can't be recovered. All data stored on instance store volumes is permanently lost. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/how-ec2-instance-termination-works.html"> How instance termination works</a>.</p>
28/// <p>Before you terminate an instance, ensure that you have backed up all data that you need to retain after the termination to persistent storage.</p>
29/// </important>
30/// <p>If you specify multiple instances and the request fails (for example, because of a single incorrect instance ID), none of the instances are terminated.</p>
31/// <p>If you terminate multiple instances across multiple Availability Zones, and one or more of the specified instances are enabled for termination protection, the request fails with the following results:</p>
32/// <ul>
33/// <li>
34/// <p>The specified instances that are in the same Availability Zone as the protected instance are not terminated.</p></li>
35/// <li>
36/// <p>The specified instances that are in different Availability Zones, where no other specified instances are protected, are successfully terminated.</p></li>
37/// </ul>
38/// <p>For example, say you have the following instances:</p>
39/// <ul>
40/// <li>
41/// <p>Instance A: <code>us-east-1a</code>; Not protected</p></li>
42/// <li>
43/// <p>Instance B: <code>us-east-1a</code>; Not protected</p></li>
44/// <li>
45/// <p>Instance C: <code>us-east-1b</code>; Protected</p></li>
46/// <li>
47/// <p>Instance D: <code>us-east-1b</code>; not protected</p></li>
48/// </ul>
49/// <p>If you attempt to terminate all of these instances in the same request, the request reports failure with the following results:</p>
50/// <ul>
51/// <li>
52/// <p>Instance A and Instance B are successfully terminated because none of the specified instances in <code>us-east-1a</code> are enabled for termination protection.</p></li>
53/// <li>
54/// <p>Instance C and Instance D fail to terminate because at least one of the specified instances in <code>us-east-1b</code> (Instance C) is enabled for termination protection.</p></li>
55/// </ul>
56/// <p>Terminated instances remain visible after termination (for approximately one hour).</p>
57/// <p>By default, Amazon EC2 deletes all EBS volumes that were attached when the instance launched. Volumes attached after instance launch continue running.</p>
58/// <p>By default, the TerminateInstances operation includes a graceful operating system (OS) shutdown. To bypass the graceful shutdown, use the <code>skipOsShutdown</code> parameter; however, this might risk data integrity.</p>
59/// <p>You can stop, start, and terminate EBS-backed instances. You can only terminate instance store-backed instances. What happens to an instance differs if you stop or terminate it. For example, when you stop an instance, the root device and any other devices attached to the instance persist. When you terminate an instance, any attached EBS volumes with the <code>DeleteOnTermination</code> block device mapping parameter set to <code>true</code> are automatically deleted. For more information about the differences between stopping and terminating instances, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-lifecycle.html">Amazon EC2 instance state changes</a> in the <i>Amazon EC2 User Guide</i>.</p>
60/// <p>When you terminate an instance, we attempt to terminate it forcibly after a short while. If your instance appears stuck in the shutting-down state after a period of time, there might be an issue with the underlying host computer. For more information about terminating and troubleshooting terminating your instances, see <a href="https://docs.aws.amazon.com/">Terminate Amazon EC2 instances</a> and <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesShuttingDown.html">Troubleshooting terminating your instance</a> in the <i>Amazon EC2 User Guide</i>.</p>
61#[derive(::std::clone::Clone, ::std::fmt::Debug)]
62pub struct TerminateInstancesFluentBuilder {
63 handle: ::std::sync::Arc<crate::client::Handle>,
64 inner: crate::operation::terminate_instances::builders::TerminateInstancesInputBuilder,
65 config_override: ::std::option::Option<crate::config::Builder>,
66}
67impl
68 crate::client::customize::internal::CustomizableSend<
69 crate::operation::terminate_instances::TerminateInstancesOutput,
70 crate::operation::terminate_instances::TerminateInstancesError,
71 > for TerminateInstancesFluentBuilder
72{
73 fn send(
74 self,
75 config_override: crate::config::Builder,
76 ) -> crate::client::customize::internal::BoxFuture<
77 crate::client::customize::internal::SendResult<
78 crate::operation::terminate_instances::TerminateInstancesOutput,
79 crate::operation::terminate_instances::TerminateInstancesError,
80 >,
81 > {
82 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
83 }
84}
85impl TerminateInstancesFluentBuilder {
86 /// Creates a new `TerminateInstancesFluentBuilder`.
87 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
88 Self {
89 handle,
90 inner: ::std::default::Default::default(),
91 config_override: ::std::option::Option::None,
92 }
93 }
94 /// Access the TerminateInstances as a reference.
95 pub fn as_input(&self) -> &crate::operation::terminate_instances::builders::TerminateInstancesInputBuilder {
96 &self.inner
97 }
98 /// Sends the request and returns the response.
99 ///
100 /// If an error occurs, an `SdkError` will be returned with additional details that
101 /// can be matched against.
102 ///
103 /// By default, any retryable failures will be retried twice. Retry behavior
104 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
105 /// set when configuring the client.
106 pub async fn send(
107 self,
108 ) -> ::std::result::Result<
109 crate::operation::terminate_instances::TerminateInstancesOutput,
110 ::aws_smithy_runtime_api::client::result::SdkError<
111 crate::operation::terminate_instances::TerminateInstancesError,
112 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
113 >,
114 > {
115 let input = self
116 .inner
117 .build()
118 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
119 let runtime_plugins = crate::operation::terminate_instances::TerminateInstances::operation_runtime_plugins(
120 self.handle.runtime_plugins.clone(),
121 &self.handle.conf,
122 self.config_override,
123 );
124 crate::operation::terminate_instances::TerminateInstances::orchestrate(&runtime_plugins, input).await
125 }
126
127 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
128 pub fn customize(
129 self,
130 ) -> crate::client::customize::CustomizableOperation<
131 crate::operation::terminate_instances::TerminateInstancesOutput,
132 crate::operation::terminate_instances::TerminateInstancesError,
133 Self,
134 > {
135 crate::client::customize::CustomizableOperation::new(self)
136 }
137 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
138 self.set_config_override(::std::option::Option::Some(config_override.into()));
139 self
140 }
141
142 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
143 self.config_override = config_override;
144 self
145 }
146 ///
147 /// Appends an item to `InstanceIds`.
148 ///
149 /// To override the contents of this collection use [`set_instance_ids`](Self::set_instance_ids).
150 ///
151 /// <p>The IDs of the instances.</p>
152 /// <p>Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.</p>
153 pub fn instance_ids(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
154 self.inner = self.inner.instance_ids(input.into());
155 self
156 }
157 /// <p>The IDs of the instances.</p>
158 /// <p>Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.</p>
159 pub fn set_instance_ids(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
160 self.inner = self.inner.set_instance_ids(input);
161 self
162 }
163 /// <p>The IDs of the instances.</p>
164 /// <p>Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.</p>
165 pub fn get_instance_ids(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
166 self.inner.get_instance_ids()
167 }
168 /// <p>Forces the instances to terminate. The instance will first attempt a graceful shutdown, which includes flushing file system caches and metadata. If the graceful shutdown fails to complete within the timeout period, the instance shuts down forcibly without flushing the file system caches and metadata.</p>
169 pub fn force(mut self, input: bool) -> Self {
170 self.inner = self.inner.force(input);
171 self
172 }
173 /// <p>Forces the instances to terminate. The instance will first attempt a graceful shutdown, which includes flushing file system caches and metadata. If the graceful shutdown fails to complete within the timeout period, the instance shuts down forcibly without flushing the file system caches and metadata.</p>
174 pub fn set_force(mut self, input: ::std::option::Option<bool>) -> Self {
175 self.inner = self.inner.set_force(input);
176 self
177 }
178 /// <p>Forces the instances to terminate. The instance will first attempt a graceful shutdown, which includes flushing file system caches and metadata. If the graceful shutdown fails to complete within the timeout period, the instance shuts down forcibly without flushing the file system caches and metadata.</p>
179 pub fn get_force(&self) -> &::std::option::Option<bool> {
180 self.inner.get_force()
181 }
182 /// <p>Specifies whether to bypass the graceful OS shutdown process when the instance is terminated.</p>
183 /// <p>Default: <code>false</code></p>
184 pub fn skip_os_shutdown(mut self, input: bool) -> Self {
185 self.inner = self.inner.skip_os_shutdown(input);
186 self
187 }
188 /// <p>Specifies whether to bypass the graceful OS shutdown process when the instance is terminated.</p>
189 /// <p>Default: <code>false</code></p>
190 pub fn set_skip_os_shutdown(mut self, input: ::std::option::Option<bool>) -> Self {
191 self.inner = self.inner.set_skip_os_shutdown(input);
192 self
193 }
194 /// <p>Specifies whether to bypass the graceful OS shutdown process when the instance is terminated.</p>
195 /// <p>Default: <code>false</code></p>
196 pub fn get_skip_os_shutdown(&self) -> &::std::option::Option<bool> {
197 self.inner.get_skip_os_shutdown()
198 }
199 /// <p>Checks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
200 pub fn dry_run(mut self, input: bool) -> Self {
201 self.inner = self.inner.dry_run(input);
202 self
203 }
204 /// <p>Checks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
205 pub fn set_dry_run(mut self, input: ::std::option::Option<bool>) -> Self {
206 self.inner = self.inner.set_dry_run(input);
207 self
208 }
209 /// <p>Checks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
210 pub fn get_dry_run(&self) -> &::std::option::Option<bool> {
211 self.inner.get_dry_run()
212 }
213}