aws_sdk_autoscaling/operation/put_lifecycle_hook/builders.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::put_lifecycle_hook::_put_lifecycle_hook_output::PutLifecycleHookOutputBuilder;
3
4pub use crate::operation::put_lifecycle_hook::_put_lifecycle_hook_input::PutLifecycleHookInputBuilder;
5
6impl crate::operation::put_lifecycle_hook::builders::PutLifecycleHookInputBuilder {
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::put_lifecycle_hook::PutLifecycleHookOutput,
13 ::aws_smithy_runtime_api::client::result::SdkError<
14 crate::operation::put_lifecycle_hook::PutLifecycleHookError,
15 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16 >,
17 > {
18 let mut fluent_builder = client.put_lifecycle_hook();
19 fluent_builder.inner = self;
20 fluent_builder.send().await
21 }
22}
23/// Fluent builder constructing a request to `PutLifecycleHook`.
24///
25/// <p>Creates or updates a lifecycle hook for the specified Auto Scaling group.</p>
26/// <p>Lifecycle hooks let you create solutions that are aware of events in the Auto Scaling instance lifecycle, and then perform a custom action on instances when the corresponding lifecycle event occurs.</p>
27/// <p>This step is a part of the procedure for adding a lifecycle hook to an Auto Scaling group:</p>
28/// <ol>
29/// <li>
30/// <p>(Optional) Create a launch template or launch configuration with a user data script that runs while an instance is in a wait state due to a lifecycle hook.</p></li>
31/// <li>
32/// <p>(Optional) Create a Lambda function and a rule that allows Amazon EventBridge to invoke your Lambda function when an instance is put into a wait state due to a lifecycle hook.</p></li>
33/// <li>
34/// <p>(Optional) Create a notification target and an IAM role. The target can be either an Amazon SQS queue or an Amazon SNS topic. The role allows Amazon EC2 Auto Scaling to publish lifecycle notifications to the target.</p></li>
35/// <li>
36/// <p><b>Create the lifecycle hook. Specify whether the hook is used when the instances launch or terminate.</b></p></li>
37/// <li>
38/// <p>If you need more time, record the lifecycle action heartbeat to keep the instance in a wait state using the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_RecordLifecycleActionHeartbeat.html">RecordLifecycleActionHeartbeat</a> API call.</p></li>
39/// <li>
40/// <p>If you finish before the timeout period ends, send a callback by using the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_CompleteLifecycleAction.html">CompleteLifecycleAction</a> API call.</p></li>
41/// </ol>
42/// <p>For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html">Amazon EC2 Auto Scaling lifecycle hooks</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>
43/// <p>If you exceed your maximum limit of lifecycle hooks, which by default is 50 per Auto Scaling group, the call fails.</p>
44/// <p>You can view the lifecycle hooks for an Auto Scaling group using the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeLifecycleHooks.html">DescribeLifecycleHooks</a> API call. If you are no longer using a lifecycle hook, you can delete it by calling the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DeleteLifecycleHook.html">DeleteLifecycleHook</a> API.</p>
45#[derive(::std::clone::Clone, ::std::fmt::Debug)]
46pub struct PutLifecycleHookFluentBuilder {
47 handle: ::std::sync::Arc<crate::client::Handle>,
48 inner: crate::operation::put_lifecycle_hook::builders::PutLifecycleHookInputBuilder,
49 config_override: ::std::option::Option<crate::config::Builder>,
50}
51impl
52 crate::client::customize::internal::CustomizableSend<
53 crate::operation::put_lifecycle_hook::PutLifecycleHookOutput,
54 crate::operation::put_lifecycle_hook::PutLifecycleHookError,
55 > for PutLifecycleHookFluentBuilder
56{
57 fn send(
58 self,
59 config_override: crate::config::Builder,
60 ) -> crate::client::customize::internal::BoxFuture<
61 crate::client::customize::internal::SendResult<
62 crate::operation::put_lifecycle_hook::PutLifecycleHookOutput,
63 crate::operation::put_lifecycle_hook::PutLifecycleHookError,
64 >,
65 > {
66 ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
67 }
68}
69impl PutLifecycleHookFluentBuilder {
70 /// Creates a new `PutLifecycleHookFluentBuilder`.
71 pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
72 Self {
73 handle,
74 inner: ::std::default::Default::default(),
75 config_override: ::std::option::Option::None,
76 }
77 }
78 /// Access the PutLifecycleHook as a reference.
79 pub fn as_input(&self) -> &crate::operation::put_lifecycle_hook::builders::PutLifecycleHookInputBuilder {
80 &self.inner
81 }
82 /// Sends the request and returns the response.
83 ///
84 /// If an error occurs, an `SdkError` will be returned with additional details that
85 /// can be matched against.
86 ///
87 /// By default, any retryable failures will be retried twice. Retry behavior
88 /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
89 /// set when configuring the client.
90 pub async fn send(
91 self,
92 ) -> ::std::result::Result<
93 crate::operation::put_lifecycle_hook::PutLifecycleHookOutput,
94 ::aws_smithy_runtime_api::client::result::SdkError<
95 crate::operation::put_lifecycle_hook::PutLifecycleHookError,
96 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
97 >,
98 > {
99 let input = self
100 .inner
101 .build()
102 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
103 let runtime_plugins = crate::operation::put_lifecycle_hook::PutLifecycleHook::operation_runtime_plugins(
104 self.handle.runtime_plugins.clone(),
105 &self.handle.conf,
106 self.config_override,
107 );
108 crate::operation::put_lifecycle_hook::PutLifecycleHook::orchestrate(&runtime_plugins, input).await
109 }
110
111 /// Consumes this builder, creating a customizable operation that can be modified before being sent.
112 pub fn customize(
113 self,
114 ) -> crate::client::customize::CustomizableOperation<
115 crate::operation::put_lifecycle_hook::PutLifecycleHookOutput,
116 crate::operation::put_lifecycle_hook::PutLifecycleHookError,
117 Self,
118 > {
119 crate::client::customize::CustomizableOperation::new(self)
120 }
121 pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
122 self.set_config_override(::std::option::Option::Some(config_override.into()));
123 self
124 }
125
126 pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
127 self.config_override = config_override;
128 self
129 }
130 /// <p>The name of the lifecycle hook.</p>
131 pub fn lifecycle_hook_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
132 self.inner = self.inner.lifecycle_hook_name(input.into());
133 self
134 }
135 /// <p>The name of the lifecycle hook.</p>
136 pub fn set_lifecycle_hook_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
137 self.inner = self.inner.set_lifecycle_hook_name(input);
138 self
139 }
140 /// <p>The name of the lifecycle hook.</p>
141 pub fn get_lifecycle_hook_name(&self) -> &::std::option::Option<::std::string::String> {
142 self.inner.get_lifecycle_hook_name()
143 }
144 /// <p>The name of the Auto Scaling group.</p>
145 pub fn auto_scaling_group_name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
146 self.inner = self.inner.auto_scaling_group_name(input.into());
147 self
148 }
149 /// <p>The name of the Auto Scaling group.</p>
150 pub fn set_auto_scaling_group_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
151 self.inner = self.inner.set_auto_scaling_group_name(input);
152 self
153 }
154 /// <p>The name of the Auto Scaling group.</p>
155 pub fn get_auto_scaling_group_name(&self) -> &::std::option::Option<::std::string::String> {
156 self.inner.get_auto_scaling_group_name()
157 }
158 /// <p>The lifecycle transition. For Auto Scaling groups, there are two major lifecycle transitions.</p>
159 /// <ul>
160 /// <li>
161 /// <p>To create a lifecycle hook for scale-out events, specify <code>autoscaling:EC2_INSTANCE_LAUNCHING</code>.</p></li>
162 /// <li>
163 /// <p>To create a lifecycle hook for scale-in events, specify <code>autoscaling:EC2_INSTANCE_TERMINATING</code>.</p></li>
164 /// </ul>
165 /// <p>Required for new lifecycle hooks, but optional when updating existing hooks.</p>
166 pub fn lifecycle_transition(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
167 self.inner = self.inner.lifecycle_transition(input.into());
168 self
169 }
170 /// <p>The lifecycle transition. For Auto Scaling groups, there are two major lifecycle transitions.</p>
171 /// <ul>
172 /// <li>
173 /// <p>To create a lifecycle hook for scale-out events, specify <code>autoscaling:EC2_INSTANCE_LAUNCHING</code>.</p></li>
174 /// <li>
175 /// <p>To create a lifecycle hook for scale-in events, specify <code>autoscaling:EC2_INSTANCE_TERMINATING</code>.</p></li>
176 /// </ul>
177 /// <p>Required for new lifecycle hooks, but optional when updating existing hooks.</p>
178 pub fn set_lifecycle_transition(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
179 self.inner = self.inner.set_lifecycle_transition(input);
180 self
181 }
182 /// <p>The lifecycle transition. For Auto Scaling groups, there are two major lifecycle transitions.</p>
183 /// <ul>
184 /// <li>
185 /// <p>To create a lifecycle hook for scale-out events, specify <code>autoscaling:EC2_INSTANCE_LAUNCHING</code>.</p></li>
186 /// <li>
187 /// <p>To create a lifecycle hook for scale-in events, specify <code>autoscaling:EC2_INSTANCE_TERMINATING</code>.</p></li>
188 /// </ul>
189 /// <p>Required for new lifecycle hooks, but optional when updating existing hooks.</p>
190 pub fn get_lifecycle_transition(&self) -> &::std::option::Option<::std::string::String> {
191 self.inner.get_lifecycle_transition()
192 }
193 /// <p>The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.</p>
194 /// <p>Valid only if the notification target is an Amazon SNS topic or an Amazon SQS queue. Required for new lifecycle hooks, but optional when updating existing hooks.</p>
195 pub fn role_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
196 self.inner = self.inner.role_arn(input.into());
197 self
198 }
199 /// <p>The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.</p>
200 /// <p>Valid only if the notification target is an Amazon SNS topic or an Amazon SQS queue. Required for new lifecycle hooks, but optional when updating existing hooks.</p>
201 pub fn set_role_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
202 self.inner = self.inner.set_role_arn(input);
203 self
204 }
205 /// <p>The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.</p>
206 /// <p>Valid only if the notification target is an Amazon SNS topic or an Amazon SQS queue. Required for new lifecycle hooks, but optional when updating existing hooks.</p>
207 pub fn get_role_arn(&self) -> &::std::option::Option<::std::string::String> {
208 self.inner.get_role_arn()
209 }
210 /// <p>The Amazon Resource Name (ARN) of the notification target that Amazon EC2 Auto Scaling uses to notify you when an instance is in a wait state for the lifecycle hook. You can specify either an Amazon SNS topic or an Amazon SQS queue.</p>
211 /// <p>If you specify an empty string, this overrides the current ARN.</p>
212 /// <p>This operation uses the JSON format when sending notifications to an Amazon SQS queue, and an email key-value pair format when sending notifications to an Amazon SNS topic.</p>
213 /// <p>When you specify a notification target, Amazon EC2 Auto Scaling sends it a test message. Test messages contain the following additional key-value pair: <code>"Event": "autoscaling:TEST_NOTIFICATION"</code>.</p>
214 pub fn notification_target_arn(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
215 self.inner = self.inner.notification_target_arn(input.into());
216 self
217 }
218 /// <p>The Amazon Resource Name (ARN) of the notification target that Amazon EC2 Auto Scaling uses to notify you when an instance is in a wait state for the lifecycle hook. You can specify either an Amazon SNS topic or an Amazon SQS queue.</p>
219 /// <p>If you specify an empty string, this overrides the current ARN.</p>
220 /// <p>This operation uses the JSON format when sending notifications to an Amazon SQS queue, and an email key-value pair format when sending notifications to an Amazon SNS topic.</p>
221 /// <p>When you specify a notification target, Amazon EC2 Auto Scaling sends it a test message. Test messages contain the following additional key-value pair: <code>"Event": "autoscaling:TEST_NOTIFICATION"</code>.</p>
222 pub fn set_notification_target_arn(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
223 self.inner = self.inner.set_notification_target_arn(input);
224 self
225 }
226 /// <p>The Amazon Resource Name (ARN) of the notification target that Amazon EC2 Auto Scaling uses to notify you when an instance is in a wait state for the lifecycle hook. You can specify either an Amazon SNS topic or an Amazon SQS queue.</p>
227 /// <p>If you specify an empty string, this overrides the current ARN.</p>
228 /// <p>This operation uses the JSON format when sending notifications to an Amazon SQS queue, and an email key-value pair format when sending notifications to an Amazon SNS topic.</p>
229 /// <p>When you specify a notification target, Amazon EC2 Auto Scaling sends it a test message. Test messages contain the following additional key-value pair: <code>"Event": "autoscaling:TEST_NOTIFICATION"</code>.</p>
230 pub fn get_notification_target_arn(&self) -> &::std::option::Option<::std::string::String> {
231 self.inner.get_notification_target_arn()
232 }
233 /// <p>Additional information that you want to include any time Amazon EC2 Auto Scaling sends a message to the notification target.</p>
234 pub fn notification_metadata(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
235 self.inner = self.inner.notification_metadata(input.into());
236 self
237 }
238 /// <p>Additional information that you want to include any time Amazon EC2 Auto Scaling sends a message to the notification target.</p>
239 pub fn set_notification_metadata(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
240 self.inner = self.inner.set_notification_metadata(input);
241 self
242 }
243 /// <p>Additional information that you want to include any time Amazon EC2 Auto Scaling sends a message to the notification target.</p>
244 pub fn get_notification_metadata(&self) -> &::std::option::Option<::std::string::String> {
245 self.inner.get_notification_metadata()
246 }
247 /// <p>The maximum time, in seconds, that can elapse before the lifecycle hook times out. The range is from <code>30</code> to <code>7200</code> seconds. The default value is <code>3600</code> seconds (1 hour).</p>
248 pub fn heartbeat_timeout(mut self, input: i32) -> Self {
249 self.inner = self.inner.heartbeat_timeout(input);
250 self
251 }
252 /// <p>The maximum time, in seconds, that can elapse before the lifecycle hook times out. The range is from <code>30</code> to <code>7200</code> seconds. The default value is <code>3600</code> seconds (1 hour).</p>
253 pub fn set_heartbeat_timeout(mut self, input: ::std::option::Option<i32>) -> Self {
254 self.inner = self.inner.set_heartbeat_timeout(input);
255 self
256 }
257 /// <p>The maximum time, in seconds, that can elapse before the lifecycle hook times out. The range is from <code>30</code> to <code>7200</code> seconds. The default value is <code>3600</code> seconds (1 hour).</p>
258 pub fn get_heartbeat_timeout(&self) -> &::std::option::Option<i32> {
259 self.inner.get_heartbeat_timeout()
260 }
261 /// <p>The action the Auto Scaling group takes when the lifecycle hook timeout elapses or if an unexpected failure occurs. The default value is <code>ABANDON</code>.</p>
262 /// <p>Valid values: <code>CONTINUE</code> | <code>ABANDON</code></p>
263 pub fn default_result(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
264 self.inner = self.inner.default_result(input.into());
265 self
266 }
267 /// <p>The action the Auto Scaling group takes when the lifecycle hook timeout elapses or if an unexpected failure occurs. The default value is <code>ABANDON</code>.</p>
268 /// <p>Valid values: <code>CONTINUE</code> | <code>ABANDON</code></p>
269 pub fn set_default_result(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
270 self.inner = self.inner.set_default_result(input);
271 self
272 }
273 /// <p>The action the Auto Scaling group takes when the lifecycle hook timeout elapses or if an unexpected failure occurs. The default value is <code>ABANDON</code>.</p>
274 /// <p>Valid values: <code>CONTINUE</code> | <code>ABANDON</code></p>
275 pub fn get_default_result(&self) -> &::std::option::Option<::std::string::String> {
276 self.inner.get_default_result()
277 }
278}