aws_sdk_autoscaling/operation/start_instance_refresh/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::start_instance_refresh::_start_instance_refresh_output::StartInstanceRefreshOutputBuilder;
3
4pub use crate::operation::start_instance_refresh::_start_instance_refresh_input::StartInstanceRefreshInputBuilder;
5
6impl crate::operation::start_instance_refresh::builders::StartInstanceRefreshInputBuilder {
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::start_instance_refresh::StartInstanceRefreshOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::start_instance_refresh::StartInstanceRefreshError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.start_instance_refresh();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `StartInstanceRefresh`.
24///
25/// <p>Starts an instance refresh.</p>
26/// <p>This operation is part of the <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-instance-refresh.html">instance refresh feature</a> in Amazon EC2 Auto Scaling, which helps you update instances in your Auto Scaling group. This feature is helpful, for example, when you have a new AMI or a new user data script. You just need to create a new launch template that specifies the new AMI or user data script. Then start an instance refresh to immediately begin the process of updating instances in the group.</p>
27/// <p>If successful, the request's response contains a unique ID that you can use to track the progress of the instance refresh. To query its status, call the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeInstanceRefreshes.html">DescribeInstanceRefreshes</a> API. To describe the instance refreshes that have already run, call the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeInstanceRefreshes.html">DescribeInstanceRefreshes</a> API. To cancel an instance refresh that is in progress, use the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_CancelInstanceRefresh.html">CancelInstanceRefresh</a> API.</p>
28/// <p>An instance refresh might fail for several reasons, such as EC2 launch failures, misconfigured health checks, or not ignoring or allowing the termination of instances that are in <code>Standby</code> state or protected from scale in. You can monitor for failed EC2 launches using the scaling activities. To find the scaling activities, call the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeScalingActivities.html">DescribeScalingActivities</a> API.</p>
29/// <p>If you enable auto rollback, your Auto Scaling group will be rolled back automatically when the instance refresh fails. You can enable this feature before starting an instance refresh by specifying the <code>AutoRollback</code> property in the instance refresh preferences. Otherwise, to roll back an instance refresh before it finishes, use the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_RollbackInstanceRefresh.html">RollbackInstanceRefresh</a> API.</p>
30#[derive(::std::clone::Clone, ::std::fmt::Debug)]
31pub struct StartInstanceRefreshFluentBuilder {
32    handle: ::std::sync::Arc<crate::client::Handle>,
33    inner: crate::operation::start_instance_refresh::builders::StartInstanceRefreshInputBuilder,
34    config_override: ::std::option::Option<crate::config::Builder>,
35}
36impl
37    crate::client::customize::internal::CustomizableSend<
38        crate::operation::start_instance_refresh::StartInstanceRefreshOutput,
39        crate::operation::start_instance_refresh::StartInstanceRefreshError,
40    > for StartInstanceRefreshFluentBuilder
41{
42    fn send(
43        self,
44        config_override: crate::config::Builder,
45    ) -> crate::client::customize::internal::BoxFuture<
46        crate::client::customize::internal::SendResult<
47            crate::operation::start_instance_refresh::StartInstanceRefreshOutput,
48            crate::operation::start_instance_refresh::StartInstanceRefreshError,
49        >,
50    > {
51        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
52    }
53}
54impl StartInstanceRefreshFluentBuilder {
55    /// Creates a new `StartInstanceRefreshFluentBuilder`.
56    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
57        Self {
58            handle,
59            inner: ::std::default::Default::default(),
60            config_override: ::std::option::Option::None,
61        }
62    }
63    /// Access the StartInstanceRefresh as a reference.
64    pub fn as_input(&self) -> &crate::operation::start_instance_refresh::builders::StartInstanceRefreshInputBuilder {
65        &self.inner
66    }
67    /// Sends the request and returns the response.
68    ///
69    /// If an error occurs, an `SdkError` will be returned with additional details that
70    /// can be matched against.
71    ///
72    /// By default, any retryable failures will be retried twice. Retry behavior
73    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
74    /// set when configuring the client.
75    pub async fn send(
76        self,
77    ) -> ::std::result::Result<
78        crate::operation::start_instance_refresh::StartInstanceRefreshOutput,
79        ::aws_smithy_runtime_api::client::result::SdkError<
80            crate::operation::start_instance_refresh::StartInstanceRefreshError,
81            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
82        >,
83    > {
84        let input = self
85            .inner
86            .build()
87            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
88        let runtime_plugins = crate::operation::start_instance_refresh::StartInstanceRefresh::operation_runtime_plugins(
89            self.handle.runtime_plugins.clone(),
90            &self.handle.conf,
91            self.config_override,
92        );
93        crate::operation::start_instance_refresh::StartInstanceRefresh::orchestrate(&runtime_plugins, input).await
94    }
95
96    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
97    pub fn customize(
98        self,
99    ) -> crate::client::customize::CustomizableOperation<
100        crate::operation::start_instance_refresh::StartInstanceRefreshOutput,
101        crate::operation::start_instance_refresh::StartInstanceRefreshError,
102        Self,
103    > {
104        crate::client::customize::CustomizableOperation::new(self)
105    }
106    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
107        self.set_config_override(::std::option::Option::Some(config_override.into()));
108        self
109    }
110
111    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
112        self.config_override = config_override;
113        self
114    }
115    /// <p>The name of the Auto Scaling group.</p>
116    pub fn auto_scaling_group_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
117        self.inner = self.inner.auto_scaling_group_name(input.into());
118        self
119    }
120    /// <p>The name of the Auto Scaling group.</p>
121    pub fn set_auto_scaling_group_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
122        self.inner = self.inner.set_auto_scaling_group_name(input);
123        self
124    }
125    /// <p>The name of the Auto Scaling group.</p>
126    pub fn get_auto_scaling_group_name(&self) -> &::std::option::Option<::std::string::String> {
127        self.inner.get_auto_scaling_group_name()
128    }
129    /// <p>The strategy to use for the instance refresh. The only valid value is <code>Rolling</code>.</p>
130    pub fn strategy(mut self, input: crate::types::RefreshStrategy) -> Self {
131        self.inner = self.inner.strategy(input);
132        self
133    }
134    /// <p>The strategy to use for the instance refresh. The only valid value is <code>Rolling</code>.</p>
135    pub fn set_strategy(mut self, input: ::std::option::Option<crate::types::RefreshStrategy>) -> Self {
136        self.inner = self.inner.set_strategy(input);
137        self
138    }
139    /// <p>The strategy to use for the instance refresh. The only valid value is <code>Rolling</code>.</p>
140    pub fn get_strategy(&self) -> &::std::option::Option<crate::types::RefreshStrategy> {
141        self.inner.get_strategy()
142    }
143    /// <p>The desired configuration. For example, the desired configuration can specify a new launch template or a new version of the current launch template.</p>
144    /// <p>Once the instance refresh succeeds, Amazon EC2 Auto Scaling updates the settings of the Auto Scaling group to reflect the new desired configuration.</p><note>
145    /// <p>When you specify a new launch template or a new version of the current launch template for your desired configuration, consider enabling the <code>SkipMatching</code> property in preferences. If it's enabled, Amazon EC2 Auto Scaling skips replacing instances that already use the specified launch template and instance types. This can help you reduce the number of replacements that are required to apply updates.</p>
146    /// </note>
147    pub fn desired_configuration(mut self, input: crate::types::DesiredConfiguration) -> Self {
148        self.inner = self.inner.desired_configuration(input);
149        self
150    }
151    /// <p>The desired configuration. For example, the desired configuration can specify a new launch template or a new version of the current launch template.</p>
152    /// <p>Once the instance refresh succeeds, Amazon EC2 Auto Scaling updates the settings of the Auto Scaling group to reflect the new desired configuration.</p><note>
153    /// <p>When you specify a new launch template or a new version of the current launch template for your desired configuration, consider enabling the <code>SkipMatching</code> property in preferences. If it's enabled, Amazon EC2 Auto Scaling skips replacing instances that already use the specified launch template and instance types. This can help you reduce the number of replacements that are required to apply updates.</p>
154    /// </note>
155    pub fn set_desired_configuration(mut self, input: ::std::option::Option<crate::types::DesiredConfiguration>) -> Self {
156        self.inner = self.inner.set_desired_configuration(input);
157        self
158    }
159    /// <p>The desired configuration. For example, the desired configuration can specify a new launch template or a new version of the current launch template.</p>
160    /// <p>Once the instance refresh succeeds, Amazon EC2 Auto Scaling updates the settings of the Auto Scaling group to reflect the new desired configuration.</p><note>
161    /// <p>When you specify a new launch template or a new version of the current launch template for your desired configuration, consider enabling the <code>SkipMatching</code> property in preferences. If it's enabled, Amazon EC2 Auto Scaling skips replacing instances that already use the specified launch template and instance types. This can help you reduce the number of replacements that are required to apply updates.</p>
162    /// </note>
163    pub fn get_desired_configuration(&self) -> &::std::option::Option<crate::types::DesiredConfiguration> {
164        self.inner.get_desired_configuration()
165    }
166    /// <p>Sets your preferences for the instance refresh so that it performs as expected when you start it. Includes the instance warmup time, the minimum and maximum healthy percentages, and the behaviors that you want Amazon EC2 Auto Scaling to use if instances that are in <code>Standby</code> state or protected from scale in are found. You can also choose to enable additional features, such as the following:</p>
167    /// <ul>
168    /// <li>
169    /// <p>Auto rollback</p></li>
170    /// <li>
171    /// <p>Checkpoints</p></li>
172    /// <li>
173    /// <p>CloudWatch alarms</p></li>
174    /// <li>
175    /// <p>Skip matching</p></li>
176    /// <li>
177    /// <p>Bake time</p></li>
178    /// </ul>
179    pub fn preferences(mut self, input: crate::types::RefreshPreferences) -> Self {
180        self.inner = self.inner.preferences(input);
181        self
182    }
183    /// <p>Sets your preferences for the instance refresh so that it performs as expected when you start it. Includes the instance warmup time, the minimum and maximum healthy percentages, and the behaviors that you want Amazon EC2 Auto Scaling to use if instances that are in <code>Standby</code> state or protected from scale in are found. You can also choose to enable additional features, such as the following:</p>
184    /// <ul>
185    /// <li>
186    /// <p>Auto rollback</p></li>
187    /// <li>
188    /// <p>Checkpoints</p></li>
189    /// <li>
190    /// <p>CloudWatch alarms</p></li>
191    /// <li>
192    /// <p>Skip matching</p></li>
193    /// <li>
194    /// <p>Bake time</p></li>
195    /// </ul>
196    pub fn set_preferences(mut self, input: ::std::option::Option<crate::types::RefreshPreferences>) -> Self {
197        self.inner = self.inner.set_preferences(input);
198        self
199    }
200    /// <p>Sets your preferences for the instance refresh so that it performs as expected when you start it. Includes the instance warmup time, the minimum and maximum healthy percentages, and the behaviors that you want Amazon EC2 Auto Scaling to use if instances that are in <code>Standby</code> state or protected from scale in are found. You can also choose to enable additional features, such as the following:</p>
201    /// <ul>
202    /// <li>
203    /// <p>Auto rollback</p></li>
204    /// <li>
205    /// <p>Checkpoints</p></li>
206    /// <li>
207    /// <p>CloudWatch alarms</p></li>
208    /// <li>
209    /// <p>Skip matching</p></li>
210    /// <li>
211    /// <p>Bake time</p></li>
212    /// </ul>
213    pub fn get_preferences(&self) -> &::std::option::Option<crate::types::RefreshPreferences> {
214        self.inner.get_preferences()
215    }
216}