Skip to content

Commit 047c131

Browse files
author
awstools
committed
feat(client-ec2): Adds support for waiters that automatically poll for a deleted NAT Gateway until it reaches the deleted state.
1 parent e7c061d commit 047c131

File tree

11 files changed

+165
-27
lines changed

11 files changed

+165
-27
lines changed

clients/client-ec2/src/EC2.ts

+16
Original file line numberDiff line numberDiff line change
@@ -20256,6 +20256,14 @@ export class EC2 extends EC2Client {
2025620256
* supported.</p>
2025720257
* <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet-requests.html">Spot Fleet requests</a>
2025820258
* in the <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
20259+
*
20260+
* <important>
20261+
* <p>We strongly discourage using the RequestSpotFleet API because it is a legacy
20262+
* API with no planned investment. For options for requesting Spot Instances, see
20263+
* <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-best-practices.html#which-spot-request-method-to-use">Which
20264+
* is the best Spot request method to use?</a> in the
20265+
* <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
20266+
* </important>
2025920267
*/
2026020268
public requestSpotFleet(
2026120269
args: RequestSpotFleetCommandInput,
@@ -20290,6 +20298,14 @@ export class EC2 extends EC2Client {
2029020298
* <p>Creates a Spot Instance request.</p>
2029120299
* <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html">Spot Instance requests</a> in
2029220300
* the <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
20301+
*
20302+
* <important>
20303+
* <p>We strongly discourage using the RequestSpotInstances API because it is a legacy
20304+
* API with no planned investment. For options for requesting Spot Instances, see
20305+
* <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-best-practices.html#which-spot-request-method-to-use">Which
20306+
* is the best Spot request method to use?</a> in the
20307+
* <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
20308+
* </important>
2029320309
*/
2029420310
public requestSpotInstances(
2029520311
args: RequestSpotInstancesCommandInput,

clients/client-ec2/src/commands/RequestSpotFleetCommand.ts

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ export interface RequestSpotFleetCommandOutput extends RequestSpotFleetResponse,
4242
* supported.</p>
4343
* <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet-requests.html">Spot Fleet requests</a>
4444
* in the <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
45+
*
46+
* <important>
47+
* <p>We strongly discourage using the RequestSpotFleet API because it is a legacy
48+
* API with no planned investment. For options for requesting Spot Instances, see
49+
* <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-best-practices.html#which-spot-request-method-to-use">Which
50+
* is the best Spot request method to use?</a> in the
51+
* <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
52+
* </important>
4553
* @example
4654
* Use a bare-bones client and the command you need to make an API call.
4755
* ```javascript

clients/client-ec2/src/commands/RequestSpotInstancesCommand.ts

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ export interface RequestSpotInstancesCommandOutput extends RequestSpotInstancesR
2525
* <p>Creates a Spot Instance request.</p>
2626
* <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-requests.html">Spot Instance requests</a> in
2727
* the <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
28+
*
29+
* <important>
30+
* <p>We strongly discourage using the RequestSpotInstances API because it is a legacy
31+
* API with no planned investment. For options for requesting Spot Instances, see
32+
* <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-best-practices.html#which-spot-request-method-to-use">Which
33+
* is the best Spot request method to use?</a> in the
34+
* <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
35+
* </important>
2836
* @example
2937
* Use a bare-bones client and the command you need to make an API call.
3038
* ```javascript

clients/client-ec2/src/models/models_1.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -3483,7 +3483,14 @@ export namespace CreateKeyPairRequest {
34833483
*/
34843484
export interface KeyPair {
34853485
/**
3486-
* <p>The SHA-1 digest of the DER encoded private key.</p>
3486+
* <ul>
3487+
* <li>
3488+
* <p>For RSA key pairs, the key fingerprint is the SHA-1 digest of the DER encoded private key.</p>
3489+
* </li>
3490+
* <li>
3491+
* <p>For ED25519 key pairs, the key fingerprint is the base64-encoded SHA-256 digest, which is the default for OpenSSH, starting with OpenSSH 6.8.</p>
3492+
* </li>
3493+
* </ul>
34873494
*/
34883495
KeyFingerprint?: string;
34893496

clients/client-ec2/src/models/models_3.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -5482,6 +5482,11 @@ export interface DescribeInstancesRequest {
54825482
* </li>
54835483
* <li>
54845484
* <p>
5485+
* <code>capacity-reservation-id</code> - The ID of the Capacity Reservation into which the
5486+
* instance was launched.</p>
5487+
* </li>
5488+
* <li>
5489+
* <p>
54855490
* <code>client-token</code> - The idempotency token you provided when you launched
54865491
* the instance.</p>
54875492
* </li>
@@ -8908,8 +8913,7 @@ export interface KeyPairInfo {
89088913
* <p>If you used <a>CreateKeyPair</a> to create the key pair:</p>
89098914
* <ul>
89108915
* <li>
8911-
* <p>For RSA key pairs, the key fingerprint is the SHA-1 digest of the DER encoded private key.
8912-
* </p>
8916+
* <p>For RSA key pairs, the key fingerprint is the SHA-1 digest of the DER encoded private key.</p>
89138917
* </li>
89148918
* <li>
89158919
* <p>For ED25519 key pairs, the key fingerprint is the base64-encoded SHA-256 digest, which

clients/client-ec2/src/models/models_4.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3930,7 +3930,7 @@ export interface DescribeSpotInstanceRequestsRequest {
39303930
* <code>state</code> - The state of the Spot Instance request (<code>open</code>
39313931
* | <code>active</code> | <code>closed</code> | <code>cancelled</code> |
39323932
* <code>failed</code>). Spot request status information can help you track
3933-
* your Amazon EC2 Spot Instance requests. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-bid-status.html">Spot
3933+
* your Amazon EC2 Spot Instance requests. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-request-status.html">Spot
39343934
* request status</a> in the <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
39353935
* </li>
39363936
* <li>
@@ -4067,7 +4067,7 @@ export interface LaunchSpecification {
40674067
ImageId?: string;
40684068

40694069
/**
4070-
* <p>The instance type.</p>
4070+
* <p>The instance type. Only one instance type can be specified.</p>
40714071
*/
40724072
InstanceType?: _InstanceType | string;
40734073

@@ -4124,7 +4124,7 @@ export type SpotInstanceState = "active" | "cancelled" | "closed" | "failed" | "
41244124
*/
41254125
export interface SpotInstanceStatus {
41264126
/**
4127-
* <p>The status code. For a list of status codes, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-bid-status.html#spot-instance-bid-status-understand">Spot status codes</a> in the <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
4127+
* <p>The status code. For a list of status codes, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-request-status.html#spot-instance-request-status-understand">Spot request status codes</a> in the <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
41284128
*/
41294129
Code?: string;
41304130

@@ -4214,8 +4214,8 @@ export interface SpotInstanceRequest {
42144214
SpotPrice?: string;
42154215

42164216
/**
4217-
* <p>The state of the Spot Instance request. Spot status information helps track your Spot
4218-
* Instance requests. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-bid-status.html">Spot status</a> in the
4217+
* <p>The state of the Spot Instance request. Spot request status information helps track your Spot
4218+
* Instance requests. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-request-status.html">Spot request status</a> in the
42194219
* <i>Amazon EC2 User Guide for Linux Instances</i>.</p>
42204220
*/
42214221
State?: SpotInstanceState | string;

clients/client-ec2/src/models/models_5.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -3073,7 +3073,14 @@ export namespace ImportKeyPairRequest {
30733073

30743074
export interface ImportKeyPairResult {
30753075
/**
3076-
* <p>The MD5 public key fingerprint as specified in section 4 of RFC 4716.</p>
3076+
* <ul>
3077+
* <li>
3078+
* <p>For RSA key pairs, the key fingerprint is the MD5 public key fingerprint as specified in section 4 of RFC 4716.</p>
3079+
* </li>
3080+
* <li>
3081+
* <p>For ED25519 key pairs, the key fingerprint is the base64-encoded SHA-256 digest, which is the default for OpenSSH, starting with <a href="http://www.openssh.com/txt/release-6.8">OpenSSH 6.8</a>.</p>
3082+
* </li>
3083+
* </ul>
30773084
*/
30783085
KeyFingerprint?: string;
30793086

@@ -6224,10 +6231,9 @@ export interface ModifySubnetAttributeRequest {
62246231
EnableDns64?: AttributeBooleanValue;
62256232

62266233
/**
6227-
* <p>The type of hostnames to assign to instances in the subnet at launch. For IPv4 only subnets, an
6228-
* instance DNS name must be based on the instance IPv4 address. For IPv6 only subnets, an instance
6229-
* DNS name must be based on the instance ID. For dual-stack subnets, you can specify whether DNS
6230-
* names use the instance IPv4 address or the instance ID.</p>
6234+
* <p>The type of hostname to assign to instances in the subnet at launch. For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an
6235+
* instance DNS name can be based on the instance IPv4 address (ip-name) or the instance ID (resource-name). For IPv6 only subnets, an instance
6236+
* DNS name must be based on the instance ID (resource-name).</p>
62316237
*/
62326238
PrivateDnsHostnameTypeOnLaunch?: HostnameType | string;
62336239

@@ -9702,7 +9708,7 @@ export interface RequestSpotLaunchSpecification {
97029708
ImageId?: string;
97039709

97049710
/**
9705-
* <p>The instance type.</p>
9711+
* <p>The instance type. Only one instance type can be specified.</p>
97069712
*/
97079713
InstanceType?: _InstanceType | string;
97089714

clients/client-ec2/src/models/models_6.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { SENSITIVE_STRING } from "@aws-sdk/smithy-client";
2+
13
import {
24
_InstanceType,
35
AddressAttribute,
@@ -1501,6 +1503,7 @@ export namespace RunInstancesRequest {
15011503
*/
15021504
export const filterSensitiveLog = (obj: RunInstancesRequest): any => ({
15031505
...obj,
1506+
...(obj.UserData && { UserData: SENSITIVE_STRING }),
15041507
});
15051508
}
15061509

clients/client-ec2/src/waiters/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export * from "./waitForInstanceTerminated";
1515
export * from "./waitForInternetGatewayExists";
1616
export * from "./waitForKeyPairExists";
1717
export * from "./waitForNatGatewayAvailable";
18+
export * from "./waitForNatGatewayDeleted";
1819
export * from "./waitForNetworkInterfaceAvailable";
1920
export * from "./waitForSecurityGroupExists";
2021
export * from "./waitForSnapshotCompleted";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { checkExceptions, createWaiter, WaiterConfiguration, WaiterResult, WaiterState } from "@aws-sdk/util-waiter";
2+
3+
import { DescribeNatGatewaysCommand, DescribeNatGatewaysCommandInput } from "../commands/DescribeNatGatewaysCommand";
4+
import { EC2Client } from "../EC2Client";
5+
6+
const checkState = async (client: EC2Client, input: DescribeNatGatewaysCommandInput): Promise<WaiterResult> => {
7+
let reason;
8+
try {
9+
const result: any = await client.send(new DescribeNatGatewaysCommand(input));
10+
reason = result;
11+
try {
12+
const returnComparator = () => {
13+
const flat_1: any[] = [].concat(...result.NatGateways);
14+
const projection_3 = flat_1.map((element_2: any) => {
15+
return element_2.State;
16+
});
17+
return projection_3;
18+
};
19+
let allStringEq_5 = returnComparator().length > 0;
20+
for (const element_4 of returnComparator()) {
21+
allStringEq_5 = allStringEq_5 && element_4 == "deleted";
22+
}
23+
if (allStringEq_5) {
24+
return { state: WaiterState.SUCCESS, reason };
25+
}
26+
} catch (e) {}
27+
} catch (exception) {
28+
reason = exception;
29+
if (exception.name && exception.name == "NatGatewayNotFound") {
30+
return { state: WaiterState.SUCCESS, reason };
31+
}
32+
}
33+
return { state: WaiterState.RETRY, reason };
34+
};
35+
/**
36+
*
37+
* @deprecated Use waitUntilNatGatewayDeleted instead. waitForNatGatewayDeleted does not throw error in non-success cases.
38+
*/
39+
export const waitForNatGatewayDeleted = async (
40+
params: WaiterConfiguration<EC2Client>,
41+
input: DescribeNatGatewaysCommandInput
42+
): Promise<WaiterResult> => {
43+
const serviceDefaults = { minDelay: 15, maxDelay: 120 };
44+
return createWaiter({ ...serviceDefaults, ...params }, input, checkState);
45+
};
46+
/**
47+
*
48+
* @param params - Waiter configuration options.
49+
* @param input - The input to DescribeNatGatewaysCommand for polling.
50+
*/
51+
export const waitUntilNatGatewayDeleted = async (
52+
params: WaiterConfiguration<EC2Client>,
53+
input: DescribeNatGatewaysCommandInput
54+
): Promise<WaiterResult> => {
55+
const serviceDefaults = { minDelay: 15, maxDelay: 120 };
56+
const result = await createWaiter({ ...serviceDefaults, ...params }, input, checkState);
57+
return checkExceptions(result);
58+
};

codegen/sdk-codegen/aws-models/ec2.json

+40-13
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)