/
CompleteLifecycleActionCommand.ts
132 lines (122 loc) · 5.78 KB
/
CompleteLifecycleActionCommand.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";
import { AutoScalingClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../AutoScalingClient";
import { CompleteLifecycleActionAnswer, CompleteLifecycleActionType } from "../models/models_0";
import {
deserializeAws_queryCompleteLifecycleActionCommand,
serializeAws_queryCompleteLifecycleActionCommand,
} from "../protocols/Aws_query";
export interface CompleteLifecycleActionCommandInput extends CompleteLifecycleActionType {}
export interface CompleteLifecycleActionCommandOutput extends CompleteLifecycleActionAnswer, __MetadataBearer {}
/**
* <p>Completes the lifecycle action for the specified token or instance with the specified
* result.</p>
* <p>This step is a part of the procedure for adding a lifecycle hook to an Auto Scaling
* group:</p>
* <ol>
* <li>
* <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>
* <li>
* <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>
* <li>
* <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>
* <li>
* <p>Create the lifecycle hook. Specify whether the hook is used when the instances
* launch or terminate.</p>
* </li>
* <li>
* <p>If you need more time, record the lifecycle action heartbeat to keep the
* instance in a wait state.</p>
* </li>
* <li>
* <p>
* <b>If you finish before the timeout period ends, send a
* callback by using the <a>CompleteLifecycleAction</a> API
* call.</b>
* </p>
* </li>
* </ol>
* <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>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { AutoScalingClient, CompleteLifecycleActionCommand } from "@aws-sdk/client-auto-scaling"; // ES Modules import
* // const { AutoScalingClient, CompleteLifecycleActionCommand } = require("@aws-sdk/client-auto-scaling"); // CommonJS import
* const client = new AutoScalingClient(config);
* const command = new CompleteLifecycleActionCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link CompleteLifecycleActionCommandInput} for command's `input` shape.
* @see {@link CompleteLifecycleActionCommandOutput} for command's `response` shape.
* @see {@link AutoScalingClientResolvedConfig | config} for AutoScalingClient's `config` shape.
*
*/
export class CompleteLifecycleActionCommand extends $Command<
CompleteLifecycleActionCommandInput,
CompleteLifecycleActionCommandOutput,
AutoScalingClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties
constructor(readonly input: CompleteLifecycleActionCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}
/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: AutoScalingClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<CompleteLifecycleActionCommandInput, CompleteLifecycleActionCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
const stack = clientStack.concat(this.middlewareStack);
const { logger } = configuration;
const clientName = "AutoScalingClient";
const commandName = "CompleteLifecycleActionCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: CompleteLifecycleActionType.filterSensitiveLog,
outputFilterSensitiveLog: CompleteLifecycleActionAnswer.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}
private serialize(input: CompleteLifecycleActionCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_queryCompleteLifecycleActionCommand(input, context);
}
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<CompleteLifecycleActionCommandOutput> {
return deserializeAws_queryCompleteLifecycleActionCommand(output, context);
}
// Start section: command_body_extra
// End section: command_body_extra
}