forked from aws/aws-sdk-js-v3
/
RecordLifecycleActionHeartbeatCommand.ts
139 lines (129 loc) · 6.06 KB
/
RecordLifecycleActionHeartbeatCommand.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
133
134
135
136
137
138
139
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 { RecordLifecycleActionHeartbeatAnswer, RecordLifecycleActionHeartbeatType } from "../models/models_0";
import {
deserializeAws_queryRecordLifecycleActionHeartbeatCommand,
serializeAws_queryRecordLifecycleActionHeartbeatCommand,
} from "../protocols/Aws_query";
export interface RecordLifecycleActionHeartbeatCommandInput extends RecordLifecycleActionHeartbeatType {}
export interface RecordLifecycleActionHeartbeatCommandOutput
extends RecordLifecycleActionHeartbeatAnswer,
__MetadataBearer {}
/**
* <p>Records a heartbeat for the lifecycle action associated with the specified token or
* instance. This extends the timeout by the length of time defined using the <a>PutLifecycleHook</a> API call.</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>
* <b>If you need more time, record the lifecycle action
* heartbeat to keep the instance in a wait state.</b>
* </p>
* </li>
* <li>
* <p>If you finish before the timeout period ends, send a callback by using the
* <a>CompleteLifecycleAction</a> API call.</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, RecordLifecycleActionHeartbeatCommand } from "@aws-sdk/client-auto-scaling"; // ES Modules import
* // const { AutoScalingClient, RecordLifecycleActionHeartbeatCommand } = require("@aws-sdk/client-auto-scaling"); // CommonJS import
* const client = new AutoScalingClient(config);
* const command = new RecordLifecycleActionHeartbeatCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link RecordLifecycleActionHeartbeatCommandInput} for command's `input` shape.
* @see {@link RecordLifecycleActionHeartbeatCommandOutput} for command's `response` shape.
* @see {@link AutoScalingClientResolvedConfig | config} for AutoScalingClient's `config` shape.
*
*/
export class RecordLifecycleActionHeartbeatCommand extends $Command<
RecordLifecycleActionHeartbeatCommandInput,
RecordLifecycleActionHeartbeatCommandOutput,
AutoScalingClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties
constructor(readonly input: RecordLifecycleActionHeartbeatCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}
/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: AutoScalingClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<RecordLifecycleActionHeartbeatCommandInput, RecordLifecycleActionHeartbeatCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
const stack = clientStack.concat(this.middlewareStack);
const { logger } = configuration;
const clientName = "AutoScalingClient";
const commandName = "RecordLifecycleActionHeartbeatCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: RecordLifecycleActionHeartbeatType.filterSensitiveLog,
outputFilterSensitiveLog: RecordLifecycleActionHeartbeatAnswer.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}
private serialize(
input: RecordLifecycleActionHeartbeatCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> {
return serializeAws_queryRecordLifecycleActionHeartbeatCommand(input, context);
}
private deserialize(
output: __HttpResponse,
context: __SerdeContext
): Promise<RecordLifecycleActionHeartbeatCommandOutput> {
return deserializeAws_queryRecordLifecycleActionHeartbeatCommand(output, context);
}
// Start section: command_body_extra
// End section: command_body_extra
}