alchemy 0.54.0 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/lib/aws/ec2/index.d.ts +10 -0
  2. package/lib/aws/ec2/index.d.ts.map +1 -0
  3. package/lib/aws/ec2/index.js +10 -0
  4. package/lib/aws/ec2/index.js.map +1 -0
  5. package/lib/aws/ec2/internet-gateway-attachment.d.ts +150 -0
  6. package/lib/aws/ec2/internet-gateway-attachment.d.ts.map +1 -0
  7. package/lib/aws/ec2/internet-gateway-attachment.js +248 -0
  8. package/lib/aws/ec2/internet-gateway-attachment.js.map +1 -0
  9. package/lib/aws/ec2/internet-gateway.d.ts +132 -0
  10. package/lib/aws/ec2/internet-gateway.d.ts.map +1 -0
  11. package/lib/aws/ec2/internet-gateway.js +311 -0
  12. package/lib/aws/ec2/internet-gateway.js.map +1 -0
  13. package/lib/aws/ec2/nat-gateway.d.ts +145 -0
  14. package/lib/aws/ec2/nat-gateway.d.ts.map +1 -0
  15. package/lib/aws/ec2/nat-gateway.js +618 -0
  16. package/lib/aws/ec2/nat-gateway.js.map +1 -0
  17. package/lib/aws/ec2/route-table-association.d.ts +134 -0
  18. package/lib/aws/ec2/route-table-association.d.ts.map +1 -0
  19. package/lib/aws/ec2/route-table-association.js +364 -0
  20. package/lib/aws/ec2/route-table-association.js.map +1 -0
  21. package/lib/aws/ec2/route-table.d.ts +94 -0
  22. package/lib/aws/ec2/route-table.d.ts.map +1 -0
  23. package/lib/aws/ec2/route-table.js +253 -0
  24. package/lib/aws/ec2/route-table.js.map +1 -0
  25. package/lib/aws/ec2/route.d.ts +130 -0
  26. package/lib/aws/ec2/route.d.ts.map +1 -0
  27. package/lib/aws/ec2/route.js +253 -0
  28. package/lib/aws/ec2/route.js.map +1 -0
  29. package/lib/aws/ec2/security-group-rule.d.ts +84 -0
  30. package/lib/aws/ec2/security-group-rule.d.ts.map +1 -0
  31. package/lib/aws/ec2/security-group-rule.js +123 -0
  32. package/lib/aws/ec2/security-group-rule.js.map +1 -0
  33. package/lib/aws/ec2/security-group.d.ts +84 -0
  34. package/lib/aws/ec2/security-group.d.ts.map +1 -0
  35. package/lib/aws/ec2/security-group.js +207 -0
  36. package/lib/aws/ec2/security-group.js.map +1 -0
  37. package/lib/aws/ec2/subnet.d.ts +110 -0
  38. package/lib/aws/ec2/subnet.d.ts.map +1 -0
  39. package/lib/aws/ec2/subnet.js +336 -0
  40. package/lib/aws/ec2/subnet.js.map +1 -0
  41. package/lib/aws/ec2/utils.d.ts +15 -0
  42. package/lib/aws/ec2/utils.d.ts.map +1 -0
  43. package/lib/aws/ec2/utils.js +79 -0
  44. package/lib/aws/ec2/utils.js.map +1 -0
  45. package/lib/aws/ec2/vpc.d.ts +160 -0
  46. package/lib/aws/ec2/vpc.d.ts.map +1 -0
  47. package/lib/aws/ec2/vpc.js +453 -0
  48. package/lib/aws/ec2/vpc.js.map +1 -0
  49. package/lib/aws/index.d.ts +7 -0
  50. package/lib/aws/index.d.ts.map +1 -1
  51. package/lib/aws/index.js +8 -0
  52. package/lib/aws/index.js.map +1 -1
  53. package/lib/aws/utils.d.ts +25 -0
  54. package/lib/aws/utils.d.ts.map +1 -0
  55. package/lib/aws/utils.js +89 -0
  56. package/lib/aws/utils.js.map +1 -0
  57. package/lib/build-date.d.ts +6 -0
  58. package/lib/build-date.d.ts.map +1 -0
  59. package/lib/build-date.js +8 -0
  60. package/lib/build-date.js.map +1 -0
  61. package/lib/util/params.d.ts +5 -0
  62. package/lib/util/params.d.ts.map +1 -0
  63. package/lib/util/params.js +30 -0
  64. package/lib/util/params.js.map +1 -0
  65. package/lib/util/timeout.d.ts +31 -0
  66. package/lib/util/timeout.d.ts.map +1 -0
  67. package/lib/util/timeout.js +109 -0
  68. package/lib/util/timeout.js.map +1 -0
  69. package/lib/util/xml.d.ts +5 -0
  70. package/lib/util/xml.d.ts.map +1 -0
  71. package/lib/util/xml.js +8 -0
  72. package/lib/util/xml.js.map +1 -0
  73. package/package.json +3 -1
  74. package/src/aws/ec2/index.ts +9 -0
  75. package/src/aws/ec2/internet-gateway-attachment.ts +468 -0
  76. package/src/aws/ec2/internet-gateway.ts +557 -0
  77. package/src/aws/ec2/nat-gateway.ts +1123 -0
  78. package/src/aws/ec2/route-table-association.ts +747 -0
  79. package/src/aws/ec2/route-table.ts +452 -0
  80. package/src/aws/ec2/route.ts +447 -0
  81. package/src/aws/ec2/security-group-rule.ts +229 -0
  82. package/src/aws/ec2/security-group.ts +418 -0
  83. package/src/aws/ec2/subnet.ts +625 -0
  84. package/src/aws/ec2/utils.ts +102 -0
  85. package/src/aws/ec2/vpc.ts +969 -0
  86. package/src/aws/index.ts +9 -0
  87. package/src/aws/utils.ts +137 -0
  88. package/src/build-date.ts +8 -0
  89. package/src/util/params.ts +33 -0
  90. package/src/util/timeout.ts +178 -0
  91. package/src/util/xml.ts +7 -0
@@ -0,0 +1,311 @@
1
+ import { XMLParser } from "fast-xml-parser";
2
+ import { Resource } from "../../resource.js";
3
+ import { ignore } from "../../util/ignore.js";
4
+ import { logger } from "../../util/logger.js";
5
+ import { mergeTimeoutConfig, waitForResourceState, } from "../../util/timeout.js";
6
+ import { callEC2Api, createEC2Client } from "./utils.js";
7
+ /**
8
+ * Wait for Internet Gateway to be in available state
9
+ */
10
+ async function waitForInternetGatewayAvailable(client, internetGatewayId, timeoutConfig) {
11
+ const checkFunction = async () => {
12
+ const response = await callEC2Api(client, "DescribeInternetGateways", parseInternetGatewayXmlResponse, {
13
+ "InternetGatewayId.1": internetGatewayId,
14
+ });
15
+ return response.InternetGateways?.[0];
16
+ };
17
+ const isReady = (igw) => {
18
+ return igw?.State === "available" || igw !== undefined; // IGWs are usually immediately available
19
+ };
20
+ await waitForResourceState(checkFunction, isReady, timeoutConfig, internetGatewayId, "Internet Gateway", "is now available");
21
+ }
22
+ /**
23
+ * Wait for Internet Gateway to be deleted
24
+ */
25
+ async function waitForInternetGatewayDeleted(client, internetGatewayId, timeoutConfig) {
26
+ const checkFunction = async () => {
27
+ try {
28
+ const response = await callEC2Api(client, "DescribeInternetGateways", parseInternetGatewayXmlResponse, {
29
+ "InternetGatewayId.1": internetGatewayId,
30
+ });
31
+ return response.InternetGateways?.[0];
32
+ }
33
+ catch (error) {
34
+ // If Internet Gateway is not found, it's been deleted - return undefined
35
+ if (error.code === "InvalidInternetGatewayID.NotFound" ||
36
+ error.code === "InvalidInternetGateway.NotFound") {
37
+ return undefined;
38
+ }
39
+ throw error;
40
+ }
41
+ };
42
+ const isReady = (igw) => {
43
+ // Internet Gateway is deleted if it doesn't exist
44
+ return !igw;
45
+ };
46
+ await waitForResourceState(checkFunction, isReady, timeoutConfig, internetGatewayId, "Internet Gateway", "deletion completed");
47
+ }
48
+ /**
49
+ * AWS Internet Gateway Resource
50
+ *
51
+ * An Internet Gateway is a horizontally scaled, redundant, and highly available VPC component
52
+ * that allows communication between your VPC and the internet. It serves two purposes:
53
+ * 1. Provide a target in your VPC route tables for internet-routable traffic
54
+ * 2. Perform network address translation (NAT) for instances with public IPv4 addresses
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * // Create a basic Internet Gateway
59
+ * const igw = new InternetGateway({
60
+ * tags: {
61
+ * Name: "my-internet-gateway",
62
+ * Environment: "production"
63
+ * }
64
+ * });
65
+ * ```
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * // Create Internet Gateway with custom timeout configuration
70
+ * const igw = new InternetGateway({
71
+ * tags: { Name: "custom-igw" },
72
+ * timeoutConfig: {
73
+ * maxAttempts: 30,
74
+ * delayMs: 1000
75
+ * }
76
+ * });
77
+ * ```
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * // Create Internet Gateway and attach to VPC
82
+ * const vpc = new VPC({ cidrBlock: "10.0.0.0/16" });
83
+ * const igw = new InternetGateway({ tags: { Name: "vpc-igw" } });
84
+ * const attachment = new InternetGatewayAttachment({
85
+ * internetGatewayId: igw.internetGatewayId,
86
+ * vpcId: vpc.vpcId
87
+ * });
88
+ * ```
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * // Access Internet Gateway properties
93
+ * const igw = new InternetGateway({ tags: { Name: "example-igw" } });
94
+ * logger.log(`Internet Gateway ID: ${igw.internetGatewayId}`);
95
+ * logger.log(`State: ${igw.state}`);
96
+ * ```
97
+ *
98
+ * Creates and manages Internet Gateways that provide internet access to VPCs.
99
+ * Note: Use InternetGatewayAttachment to attach the gateway to a VPC.
100
+ *
101
+ * @example
102
+ * // Create a basic Internet Gateway
103
+ * const igw = await InternetGateway("main-igw", {
104
+ * tags: {
105
+ * Name: "main-internet-gateway",
106
+ * Environment: "production"
107
+ * }
108
+ * });
109
+ *
110
+ * @example
111
+ * // Create an Internet Gateway for development environment
112
+ * const devIgw = await InternetGateway("dev-igw", {
113
+ * tags: {
114
+ * Name: "dev-internet-gateway",
115
+ * Environment: "development",
116
+ * Team: "backend"
117
+ * }
118
+ * });
119
+ *
120
+ * @example
121
+ * // Create an Internet Gateway with custom timeout configuration
122
+ * const customIgw = await InternetGateway("custom-igw", {
123
+ * timeout: {
124
+ * maxAttempts: 90,
125
+ * delayMs: 1500
126
+ * },
127
+ * tags: {
128
+ * Name: "custom-timeout-igw",
129
+ * Purpose: "high-availability"
130
+ * }
131
+ * });
132
+ */
133
+ export const InternetGateway = Resource("aws::InternetGateway", async function (_id, props) {
134
+ const client = await createEC2Client();
135
+ const timeoutConfig = mergeTimeoutConfig(INTERNET_GATEWAY_TIMEOUT, props.timeout);
136
+ if (this.phase === "delete") {
137
+ if (this.output?.internetGatewayId) {
138
+ logger.log(`🗑️ Deleting Internet Gateway: ${this.output.internetGatewayId}`);
139
+ // Simply delete the Internet Gateway - attachments should handle themselves
140
+ await ignore("InvalidInternetGatewayID.NotFound", async () => {
141
+ await callEC2Api(client, "DeleteInternetGateway", parseInternetGatewayXmlResponse, {
142
+ InternetGatewayId: this.output.internetGatewayId,
143
+ });
144
+ });
145
+ // Wait for Internet Gateway to be fully deleted
146
+ await waitForInternetGatewayDeleted(client, this.output.internetGatewayId, timeoutConfig);
147
+ logger.log(` ✅ Internet Gateway ${this.output.internetGatewayId} deletion completed`);
148
+ }
149
+ return this.destroy();
150
+ }
151
+ let internetGateway;
152
+ if (this.phase === "update" && this.output?.internetGatewayId) {
153
+ // Get existing Internet Gateway
154
+ const response = await callEC2Api(client, "DescribeInternetGateways", parseInternetGatewayXmlResponse, {
155
+ "InternetGatewayId.1": this.output.internetGatewayId,
156
+ });
157
+ if (!response.InternetGateways?.[0]) {
158
+ throw new Error(`Internet Gateway ${this.output.internetGatewayId} not found`);
159
+ }
160
+ internetGateway = response.InternetGateways[0];
161
+ }
162
+ else {
163
+ // Create new Internet Gateway
164
+ const createInternetGatewayParams = {};
165
+ // Add tags if provided
166
+ if (props.tags) {
167
+ createInternetGatewayParams.TagSpecifications = [
168
+ {
169
+ ResourceType: "internet-gateway",
170
+ Tags: Object.entries(props.tags).map(([key, value]) => ({
171
+ Key: key,
172
+ Value: value,
173
+ })),
174
+ },
175
+ ];
176
+ }
177
+ const createParams = convertCreateInternetGatewayParamsToAwsFormat(createInternetGatewayParams);
178
+ const response = await callEC2Api(client, "CreateInternetGateway", parseInternetGatewayXmlResponse, createParams);
179
+ if (!response.InternetGateway) {
180
+ throw new Error("Failed to create Internet Gateway");
181
+ }
182
+ internetGateway = response.InternetGateway;
183
+ // Wait for Internet Gateway to be available
184
+ await waitForInternetGatewayAvailable(client, internetGateway.InternetGatewayId, timeoutConfig);
185
+ }
186
+ return this({
187
+ internetGatewayId: internetGateway.InternetGatewayId,
188
+ state: "available",
189
+ attachments: internetGateway.Attachments?.map((att) => ({
190
+ vpcId: att.VpcId,
191
+ state: att.State,
192
+ })),
193
+ ownerId: internetGateway.OwnerId,
194
+ ...props,
195
+ });
196
+ });
197
+ /**
198
+ * Internet Gateway timeout constants
199
+ */
200
+ export const INTERNET_GATEWAY_TIMEOUT = {
201
+ maxAttempts: 60,
202
+ delayMs: 2000, // 2 seconds - IGWs are medium speed resources
203
+ };
204
+ /**
205
+ * Helper functions to convert typed parameters to AWS API format
206
+ */
207
+ function convertCreateInternetGatewayParamsToAwsFormat(params) {
208
+ const awsParams = {};
209
+ if (params.DryRun !== undefined) {
210
+ awsParams.DryRun = params.DryRun.toString();
211
+ }
212
+ // Handle TagSpecifications
213
+ if (params.TagSpecifications) {
214
+ params.TagSpecifications.forEach((tagSpec, specIndex) => {
215
+ const specNum = specIndex + 1;
216
+ awsParams[`TagSpecification.${specNum}.ResourceType`] =
217
+ tagSpec.ResourceType;
218
+ tagSpec.Tags.forEach((tag, tagIndex) => {
219
+ const tagNum = tagIndex + 1;
220
+ awsParams[`TagSpecification.${specNum}.Tag.${tagNum}.Key`] = tag.Key;
221
+ awsParams[`TagSpecification.${specNum}.Tag.${tagNum}.Value`] =
222
+ tag.Value;
223
+ });
224
+ });
225
+ }
226
+ return awsParams;
227
+ }
228
+ /**
229
+ * Parse XML responses specifically for Internet Gateway operations
230
+ */
231
+ function parseInternetGatewayXmlResponse(xmlText) {
232
+ const parser = new XMLParser({
233
+ ignoreAttributes: true,
234
+ parseAttributeValue: true,
235
+ parseTagValue: true,
236
+ trimValues: true,
237
+ });
238
+ const parsed = parser.parse(xmlText);
239
+ const result = {};
240
+ // Parse CreateInternetGatewayResponse
241
+ if (parsed.CreateInternetGatewayResponse) {
242
+ const internetGateway = parsed.CreateInternetGatewayResponse
243
+ .internetGateway;
244
+ if (internetGateway) {
245
+ result.InternetGateway = {
246
+ InternetGatewayId: internetGateway.internetGatewayId,
247
+ State: "available", // Internet Gateways are immediately available
248
+ Attachments: internetGateway.attachmentSet?.item
249
+ ? (Array.isArray(internetGateway.attachmentSet.item)
250
+ ? internetGateway.attachmentSet.item
251
+ : [internetGateway.attachmentSet.item]).map((attachment) => ({
252
+ VpcId: attachment.vpcId,
253
+ State: attachment.state,
254
+ }))
255
+ : [],
256
+ Tags: internetGateway.tagSet?.item
257
+ ? Array.isArray(internetGateway.tagSet.item)
258
+ ? internetGateway.tagSet.item.map((tag) => ({
259
+ Key: tag.key,
260
+ Value: tag.value,
261
+ }))
262
+ : [
263
+ {
264
+ Key: internetGateway.tagSet.item.key,
265
+ Value: internetGateway.tagSet.item.value,
266
+ },
267
+ ]
268
+ : undefined,
269
+ OwnerId: internetGateway.ownerId,
270
+ };
271
+ }
272
+ }
273
+ // Parse DescribeInternetGatewaysResponse
274
+ if (parsed.DescribeInternetGatewaysResponse) {
275
+ const internetGatewaySet = parsed.DescribeInternetGatewaysResponse.internetGatewaySet;
276
+ if (internetGatewaySet?.item) {
277
+ const igws = Array.isArray(internetGatewaySet.item)
278
+ ? internetGatewaySet.item
279
+ : [internetGatewaySet.item];
280
+ result.InternetGateways = igws.map((igw) => ({
281
+ InternetGatewayId: igw.internetGatewayId,
282
+ State: "available",
283
+ Attachments: igw.attachmentSet?.item
284
+ ? (Array.isArray(igw.attachmentSet.item)
285
+ ? igw.attachmentSet.item
286
+ : [igw.attachmentSet.item]).map((attachment) => ({
287
+ VpcId: attachment.vpcId,
288
+ State: attachment.state,
289
+ }))
290
+ : [],
291
+ Tags: igw.tagSet?.item
292
+ ? Array.isArray(igw.tagSet.item)
293
+ ? igw.tagSet.item.map((tag) => ({ Key: tag.key, Value: tag.value }))
294
+ : [{ Key: igw.tagSet.item.key, Value: igw.tagSet.item.value }]
295
+ : undefined,
296
+ OwnerId: igw.ownerId,
297
+ }));
298
+ }
299
+ else {
300
+ result.InternetGateways = [];
301
+ }
302
+ }
303
+ // Handle success responses
304
+ if (parsed.AttachInternetGatewayResponse ||
305
+ parsed.DetachInternetGatewayResponse ||
306
+ parsed.DeleteInternetGatewayResponse) {
307
+ result.success = true;
308
+ }
309
+ return result;
310
+ }
311
+ //# sourceMappingURL=internet-gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internet-gateway.js","sourceRoot":"","sources":["../../../src/aws/ec2/internet-gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAA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,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,IACE,MAAM,CAAC,6BAA6B;QACpC,MAAM,CAAC,6BAA6B;QACpC,MAAM,CAAC,6BAA6B,EACpC,CAAC;QACD,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,145 @@
1
+ import type { Context } from "../../context.ts";
2
+ import { Resource } from "../../resource.ts";
3
+ import { type TimeoutConfig } from "../../util/timeout.ts";
4
+ import type { Subnet } from "./subnet.ts";
5
+ /**
6
+ * Properties for creating or updating a NAT Gateway
7
+ */
8
+ export interface NatGatewayProps {
9
+ /**
10
+ * The subnet to create the NAT Gateway in (must be a public subnet)
11
+ */
12
+ subnet: Subnet | string;
13
+ /**
14
+ * The allocation ID of an existing Elastic IP address
15
+ * If not provided, a new Elastic IP will be allocated
16
+ */
17
+ allocationId?: string;
18
+ /**
19
+ * The connectivity type for the NAT Gateway
20
+ * @default "public"
21
+ */
22
+ connectivityType?: "public" | "private";
23
+ /**
24
+ * Tags to apply to the NAT Gateway
25
+ */
26
+ tags?: Record<string, string>;
27
+ /**
28
+ * Timeout configuration for NAT Gateway operations
29
+ * @default NAT Gateway-specific sensible defaults (60 attempts, 5000ms delay)
30
+ */
31
+ timeout?: Partial<TimeoutConfig>;
32
+ }
33
+ /**
34
+ * Output returned after NAT Gateway creation/update
35
+ */
36
+ export interface NatGateway extends Resource<"aws::NatGateway">, NatGatewayProps {
37
+ /**
38
+ * The ID of the NAT Gateway
39
+ */
40
+ natGatewayId: string;
41
+ /**
42
+ * The ID of the subnet the NAT Gateway is in
43
+ */
44
+ subnetId: string;
45
+ /**
46
+ * The ID of the VPC the NAT Gateway belongs to
47
+ */
48
+ vpcId: string;
49
+ /**
50
+ * The current state of the NAT Gateway
51
+ */
52
+ state: "pending" | "failed" | "available" | "deleting" | "deleted";
53
+ /**
54
+ * The allocation ID of the Elastic IP address
55
+ */
56
+ allocationId: string;
57
+ /**
58
+ * The public IP address of the NAT Gateway
59
+ */
60
+ publicIp?: string;
61
+ /**
62
+ * The private IP address of the NAT Gateway
63
+ */
64
+ privateIp?: string;
65
+ /**
66
+ * Whether the Elastic IP was created by this resource
67
+ */
68
+ createdElasticIp: boolean;
69
+ }
70
+ /**
71
+ * AWS NAT Gateway Resource
72
+ *
73
+ * Creates and manages NAT Gateways that provide outbound internet access
74
+ * for instances in private subnets. Automatically allocates an Elastic IP
75
+ * if one is not provided. NAT Gateways are slow resources that can take
76
+ * up to 10 minutes to become available.
77
+ *
78
+ * @example
79
+ * // Create a NAT Gateway with automatic Elastic IP allocation
80
+ * const natGateway = await NatGateway("main-nat", {
81
+ * subnet: publicSubnet,
82
+ * tags: {
83
+ * Name: "main-nat-gateway",
84
+ * Environment: "production"
85
+ * }
86
+ * });
87
+ *
88
+ * @example
89
+ * // Create a NAT Gateway with existing Elastic IP
90
+ * const natGateway = await NatGateway("custom-nat", {
91
+ * subnet: "subnet-12345678",
92
+ * allocationId: "eipalloc-12345678",
93
+ * connectivityType: "public",
94
+ * tags: {
95
+ * Name: "custom-nat-gateway"
96
+ * }
97
+ * });
98
+ *
99
+ * @example
100
+ * // Create a private NAT Gateway (for VPC-to-VPC communication)
101
+ * const privateNat = await NatGateway("private-nat", {
102
+ * subnet: privateSubnet,
103
+ * connectivityType: "private",
104
+ * tags: {
105
+ * Name: "private-nat-gateway",
106
+ * Type: "internal"
107
+ * }
108
+ * });
109
+ *
110
+ * @example
111
+ * // Create a NAT Gateway with custom timeout configuration
112
+ * const slowNat = await NatGateway("slow-nat", {
113
+ * subnet: publicSubnet,
114
+ * timeout: {
115
+ * maxAttempts: 180, // Wait up to 15 minutes
116
+ * delayMs: 5000 // Check every 5 seconds
117
+ * },
118
+ * tags: {
119
+ * Name: "slow-nat-gateway"
120
+ * }
121
+ * });
122
+ *
123
+ * @example
124
+ * // Use NAT Gateway in route table for private subnet internet access
125
+ * const privateRoute = await Route("private-internet", {
126
+ * routeTable: privateRouteTable,
127
+ * destinationCidrBlock: "0.0.0.0/0",
128
+ * natGateway: natGateway,
129
+ * tags: {
130
+ * Name: "private-to-internet"
131
+ * }
132
+ * });
133
+ */
134
+ export declare const NatGateway: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<NatGateway>, _id: string, props: NatGatewayProps) => Promise<NatGateway>);
135
+ /**
136
+ * Non-retryable error for NAT Gateway operations
137
+ */
138
+ export declare class NatGatewayNonRetryableError extends Error {
139
+ constructor(message: string);
140
+ }
141
+ /**
142
+ * NAT Gateway timeout constants
143
+ */
144
+ export declare const NAT_GATEWAY_TIMEOUT: TimeoutConfig;
145
+ //# sourceMappingURL=nat-gateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nat-gateway.d.ts","sourceRoot":"","sources":["../../../src/aws/ec2/nat-gateway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAExC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,UACf,SAAQ,QAAQ,CAAC,iB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