alchemy-effect 0.3.0 → 0.4.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 (158) hide show
  1. package/bin/alchemy-effect.js +539 -223
  2. package/bin/alchemy-effect.js.map +1 -1
  3. package/lib/apply.d.ts +4 -4
  4. package/lib/apply.d.ts.map +1 -1
  5. package/lib/apply.js +411 -131
  6. package/lib/apply.js.map +1 -1
  7. package/lib/aws/dynamodb/table.provider.d.ts.map +1 -1
  8. package/lib/aws/dynamodb/table.provider.js +1 -0
  9. package/lib/aws/dynamodb/table.provider.js.map +1 -1
  10. package/lib/aws/ec2/index.d.ts +8 -0
  11. package/lib/aws/ec2/index.d.ts.map +1 -1
  12. package/lib/aws/ec2/index.js +8 -0
  13. package/lib/aws/ec2/index.js.map +1 -1
  14. package/lib/aws/ec2/internet-gateway.d.ts +65 -0
  15. package/lib/aws/ec2/internet-gateway.d.ts.map +1 -0
  16. package/lib/aws/ec2/internet-gateway.js +4 -0
  17. package/lib/aws/ec2/internet-gateway.js.map +1 -0
  18. package/lib/aws/ec2/internet-gateway.provider.d.ts +6 -0
  19. package/lib/aws/ec2/internet-gateway.provider.d.ts.map +1 -0
  20. package/lib/aws/ec2/internet-gateway.provider.js +193 -0
  21. package/lib/aws/ec2/internet-gateway.provider.js.map +1 -0
  22. package/lib/aws/ec2/route-table-association.d.ts +63 -0
  23. package/lib/aws/ec2/route-table-association.d.ts.map +1 -0
  24. package/lib/aws/ec2/route-table-association.js +4 -0
  25. package/lib/aws/ec2/route-table-association.js.map +1 -0
  26. package/lib/aws/ec2/route-table-association.provider.d.ts +4 -0
  27. package/lib/aws/ec2/route-table-association.provider.d.ts.map +1 -0
  28. package/lib/aws/ec2/route-table-association.provider.js +121 -0
  29. package/lib/aws/ec2/route-table-association.provider.js.map +1 -0
  30. package/lib/aws/ec2/route-table.d.ts +159 -0
  31. package/lib/aws/ec2/route-table.d.ts.map +1 -0
  32. package/lib/aws/ec2/route-table.js +4 -0
  33. package/lib/aws/ec2/route-table.js.map +1 -0
  34. package/lib/aws/ec2/route-table.provider.d.ts +6 -0
  35. package/lib/aws/ec2/route-table.provider.d.ts.map +1 -0
  36. package/lib/aws/ec2/route-table.provider.js +213 -0
  37. package/lib/aws/ec2/route-table.provider.js.map +1 -0
  38. package/lib/aws/ec2/route.d.ts +155 -0
  39. package/lib/aws/ec2/route.d.ts.map +1 -0
  40. package/lib/aws/ec2/route.js +3 -0
  41. package/lib/aws/ec2/route.js.map +1 -0
  42. package/lib/aws/ec2/route.provider.d.ts +4 -0
  43. package/lib/aws/ec2/route.provider.d.ts.map +1 -0
  44. package/lib/aws/ec2/route.provider.js +166 -0
  45. package/lib/aws/ec2/route.provider.js.map +1 -0
  46. package/lib/aws/ec2/subnet.provider.d.ts.map +1 -1
  47. package/lib/aws/ec2/subnet.provider.js +1 -1
  48. package/lib/aws/ec2/subnet.provider.js.map +1 -1
  49. package/lib/aws/ec2/vpc.d.ts +1 -0
  50. package/lib/aws/ec2/vpc.d.ts.map +1 -1
  51. package/lib/aws/ec2/vpc.provider.d.ts +2 -2
  52. package/lib/aws/ec2/vpc.provider.d.ts.map +1 -1
  53. package/lib/aws/ec2/vpc.provider.js +38 -15
  54. package/lib/aws/ec2/vpc.provider.js.map +1 -1
  55. package/lib/aws/index.d.ts +2 -3
  56. package/lib/aws/index.d.ts.map +1 -1
  57. package/lib/aws/index.js +2 -1
  58. package/lib/aws/index.js.map +1 -1
  59. package/lib/aws/lambda/function.provider.d.ts +2 -2
  60. package/lib/aws/lambda/function.provider.d.ts.map +1 -1
  61. package/lib/aws/lambda/function.provider.js +21 -20
  62. package/lib/aws/lambda/function.provider.js.map +1 -1
  63. package/lib/aws/sqs/queue.provider.d.ts +2 -2
  64. package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
  65. package/lib/aws/sqs/queue.provider.js +3 -2
  66. package/lib/aws/sqs/queue.provider.js.map +1 -1
  67. package/lib/cli/index.d.ts +178 -99
  68. package/lib/cli/index.d.ts.map +1 -1
  69. package/lib/cloudflare/kv/namespace.client.d.ts +1 -1
  70. package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -1
  71. package/lib/cloudflare/kv/namespace.provider.js +1 -0
  72. package/lib/cloudflare/kv/namespace.provider.js.map +1 -1
  73. package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -1
  74. package/lib/cloudflare/r2/bucket.provider.js +6 -1
  75. package/lib/cloudflare/r2/bucket.provider.js.map +1 -1
  76. package/lib/cloudflare/worker/worker.provider.d.ts +1 -1
  77. package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -1
  78. package/lib/cloudflare/worker/worker.provider.js +6 -2
  79. package/lib/cloudflare/worker/worker.provider.js.map +1 -1
  80. package/lib/diff.d.ts +8 -6
  81. package/lib/diff.d.ts.map +1 -1
  82. package/lib/diff.js +13 -0
  83. package/lib/diff.js.map +1 -1
  84. package/lib/event.d.ts +1 -1
  85. package/lib/event.d.ts.map +1 -1
  86. package/lib/instance-id.d.ts +8 -0
  87. package/lib/instance-id.d.ts.map +1 -0
  88. package/lib/instance-id.js +12 -0
  89. package/lib/instance-id.js.map +1 -0
  90. package/lib/output.d.ts +4 -2
  91. package/lib/output.d.ts.map +1 -1
  92. package/lib/output.js +18 -4
  93. package/lib/output.js.map +1 -1
  94. package/lib/physical-name.d.ts +14 -1
  95. package/lib/physical-name.d.ts.map +1 -1
  96. package/lib/physical-name.js +41 -2
  97. package/lib/physical-name.js.map +1 -1
  98. package/lib/plan.d.ts +49 -42
  99. package/lib/plan.d.ts.map +1 -1
  100. package/lib/plan.js +359 -127
  101. package/lib/plan.js.map +1 -1
  102. package/lib/provider.d.ts +26 -9
  103. package/lib/provider.d.ts.map +1 -1
  104. package/lib/provider.js +9 -0
  105. package/lib/provider.js.map +1 -1
  106. package/lib/resource.d.ts +2 -2
  107. package/lib/resource.d.ts.map +1 -1
  108. package/lib/resource.js.map +1 -1
  109. package/lib/state.d.ts +86 -9
  110. package/lib/state.d.ts.map +1 -1
  111. package/lib/state.js +21 -18
  112. package/lib/state.js.map +1 -1
  113. package/lib/tags.d.ts +15 -0
  114. package/lib/tags.d.ts.map +1 -1
  115. package/lib/tags.js +27 -0
  116. package/lib/tags.js.map +1 -1
  117. package/lib/test.d.ts +2 -2
  118. package/lib/test.d.ts.map +1 -1
  119. package/lib/test.js +4 -4
  120. package/lib/test.js.map +1 -1
  121. package/lib/todo.d.ts +3 -0
  122. package/lib/todo.d.ts.map +1 -0
  123. package/lib/todo.js +3 -0
  124. package/lib/todo.js.map +1 -0
  125. package/lib/tsconfig.test.tsbuildinfo +1 -1
  126. package/package.json +2 -2
  127. package/src/apply.ts +758 -374
  128. package/src/aws/dynamodb/table.provider.ts +1 -0
  129. package/src/aws/ec2/index.ts +8 -0
  130. package/src/aws/ec2/internet-gateway.provider.ts +316 -0
  131. package/src/aws/ec2/internet-gateway.ts +79 -0
  132. package/src/aws/ec2/route-table-association.provider.ts +214 -0
  133. package/src/aws/ec2/route-table-association.ts +82 -0
  134. package/src/aws/ec2/route-table.provider.ts +306 -0
  135. package/src/aws/ec2/route-table.ts +175 -0
  136. package/src/aws/ec2/route.provider.ts +213 -0
  137. package/src/aws/ec2/route.ts +192 -0
  138. package/src/aws/ec2/subnet.provider.ts +2 -2
  139. package/src/aws/ec2/vpc.provider.ts +43 -19
  140. package/src/aws/ec2/vpc.ts +2 -0
  141. package/src/aws/index.ts +4 -1
  142. package/src/aws/lambda/function.provider.ts +25 -23
  143. package/src/aws/sqs/queue.provider.ts +3 -2
  144. package/src/cloudflare/kv/namespace.provider.ts +1 -0
  145. package/src/cloudflare/r2/bucket.provider.ts +7 -1
  146. package/src/cloudflare/worker/worker.provider.ts +6 -2
  147. package/src/diff.ts +35 -17
  148. package/src/event.ts +6 -0
  149. package/src/instance-id.ts +16 -0
  150. package/src/output.ts +29 -5
  151. package/src/physical-name.ts +57 -2
  152. package/src/plan.ts +488 -197
  153. package/src/provider.ts +46 -9
  154. package/src/resource.ts +50 -4
  155. package/src/state.ts +150 -35
  156. package/src/tags.ts +31 -0
  157. package/src/test.ts +5 -5
  158. package/src/todo.ts +4 -0
@@ -0,0 +1,82 @@
1
+ import type * as EC2 from "itty-aws/ec2";
2
+ import type { Input } from "../../input.ts";
3
+ import { Resource } from "../../resource.ts";
4
+ import type { RouteTableId } from "./route-table.ts";
5
+ import type { SubnetId } from "./subnet.ts";
6
+
7
+ export const RouteTableAssociation = Resource<{
8
+ <const ID extends string, const Props extends RouteTableAssociationProps>(
9
+ id: ID,
10
+ props: Props,
11
+ ): RouteTableAssociation<ID, Props>;
12
+ }>("AWS.EC2.RouteTableAssociation");
13
+
14
+ export interface RouteTableAssociation<
15
+ ID extends string = string,
16
+ Props extends RouteTableAssociationProps = RouteTableAssociationProps,
17
+ > extends Resource<
18
+ "AWS.EC2.RouteTableAssociation",
19
+ ID,
20
+ Props,
21
+ RouteTableAssociationAttrs<Input.Resolve<Props>>,
22
+ RouteTableAssociation
23
+ > {}
24
+
25
+ export type RouteTableAssociationId<ID extends string = string> =
26
+ `rtbassoc-${ID}`;
27
+ export const RouteTableAssociationId = <ID extends string>(
28
+ id: ID,
29
+ ): ID & RouteTableAssociationId<ID> =>
30
+ `rtbassoc-${id}` as ID & RouteTableAssociationId<ID>;
31
+
32
+ export interface RouteTableAssociationProps {
33
+ /**
34
+ * The ID of the route table.
35
+ * Required.
36
+ */
37
+ routeTableId: Input<RouteTableId>;
38
+
39
+ /**
40
+ * The ID of the subnet to associate with the route table.
41
+ * Either subnetId or gatewayId is required, but not both.
42
+ */
43
+ subnetId?: Input<SubnetId>;
44
+
45
+ /**
46
+ * The ID of the gateway (internet gateway or virtual private gateway) to associate with the route table.
47
+ * Either subnetId or gatewayId is required, but not both.
48
+ */
49
+ gatewayId?: Input<string>;
50
+ }
51
+
52
+ export interface RouteTableAssociationAttrs<
53
+ Props extends RouteTableAssociationProps,
54
+ > {
55
+ /**
56
+ * The ID of the association.
57
+ */
58
+ associationId: RouteTableAssociationId;
59
+
60
+ /**
61
+ * The ID of the route table.
62
+ */
63
+ routeTableId: Props["routeTableId"];
64
+
65
+ /**
66
+ * The ID of the subnet (if the association is with a subnet).
67
+ */
68
+ subnetId?: Props["subnetId"];
69
+
70
+ /**
71
+ * The ID of the gateway (if the association is with a gateway).
72
+ */
73
+ gatewayId?: Props["gatewayId"];
74
+
75
+ /**
76
+ * The state of the association.
77
+ */
78
+ associationState: {
79
+ state: EC2.RouteTableAssociationStateCode;
80
+ statusMessage?: string;
81
+ };
82
+ }
@@ -0,0 +1,306 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Schedule from "effect/Schedule";
3
+
4
+ import type { EC2 } from "itty-aws/ec2";
5
+
6
+ import type { ScopedPlanStatusSession } from "../../cli/service.ts";
7
+ import type { ProviderService } from "../../provider.ts";
8
+ import { createTagger, createTagsList } from "../../tags.ts";
9
+ import { Account } from "../account.ts";
10
+ import { Region } from "../region.ts";
11
+ import { EC2Client } from "./client.ts";
12
+ import {
13
+ RouteTable,
14
+ type RouteTableAttrs,
15
+ type RouteTableId,
16
+ type RouteTableProps,
17
+ } from "./route-table.ts";
18
+
19
+ export const routeTableProvider = () =>
20
+ RouteTable.provider.effect(
21
+ Effect.gen(function* () {
22
+ const ec2 = yield* EC2Client;
23
+ const region = yield* Region;
24
+ const accountId = yield* Account;
25
+ const tagged = yield* createTagger();
26
+
27
+ return {
28
+ stables: ["routeTableId", "ownerId", "routeTableArn", "vpcId"],
29
+ diff: Effect.fn(function* ({ news, olds }) {
30
+ // VpcId change requires replacement
31
+ if (olds.vpcId !== news.vpcId) {
32
+ return { action: "replace" };
33
+ }
34
+ // Tags can be updated in-place
35
+ }),
36
+
37
+ create: Effect.fn(function* ({ id, news, session }) {
38
+ // 1. Prepare tags
39
+ const alchemyTags = tagged(id);
40
+ const userTags = news.tags ?? {};
41
+ const allTags = { ...alchemyTags, ...userTags };
42
+
43
+ // 2. Call CreateRouteTable
44
+ const createResult = yield* ec2
45
+ .createRouteTable({
46
+ VpcId: news.vpcId,
47
+ TagSpecifications: [
48
+ {
49
+ ResourceType: "route-table",
50
+ Tags: createTagsList(allTags),
51
+ },
52
+ ],
53
+ DryRun: false,
54
+ })
55
+ .pipe(
56
+ Effect.retry({
57
+ // Retry if VPC is not yet available
58
+ while: (e) => e._tag === "InvalidVpcID.NotFound",
59
+ schedule: Schedule.exponential(100),
60
+ }),
61
+ );
62
+
63
+ const routeTableId = createResult.RouteTable!
64
+ .RouteTableId! as RouteTableId;
65
+ yield* session.note(`Route table created: ${routeTableId}`);
66
+
67
+ // 3. Describe to get full details
68
+ const routeTable = yield* describeRouteTable(
69
+ ec2,
70
+ routeTableId,
71
+ session,
72
+ );
73
+
74
+ // 4. Return attributes
75
+ return {
76
+ routeTableId,
77
+ routeTableArn:
78
+ `arn:aws:ec2:${region}:${accountId}:route-table/${routeTableId}` as RouteTableAttrs<RouteTableProps>["routeTableArn"],
79
+ vpcId: news.vpcId,
80
+ ownerId: routeTable.OwnerId,
81
+ associations: routeTable.Associations?.map((assoc) => ({
82
+ main: assoc.Main ?? false,
83
+ routeTableAssociationId: assoc.RouteTableAssociationId,
84
+ routeTableId: assoc.RouteTableId,
85
+ subnetId: assoc.SubnetId,
86
+ gatewayId: assoc.GatewayId,
87
+ associationState: assoc.AssociationState
88
+ ? {
89
+ state: assoc.AssociationState.State!,
90
+ statusMessage: assoc.AssociationState.StatusMessage,
91
+ }
92
+ : undefined,
93
+ })),
94
+ routes: routeTable.Routes?.map((route) => ({
95
+ destinationCidrBlock: route.DestinationCidrBlock,
96
+ destinationIpv6CidrBlock: route.DestinationIpv6CidrBlock,
97
+ destinationPrefixListId: route.DestinationPrefixListId,
98
+ egressOnlyInternetGatewayId: route.EgressOnlyInternetGatewayId,
99
+ gatewayId: route.GatewayId,
100
+ instanceId: route.InstanceId,
101
+ instanceOwnerId: route.InstanceOwnerId,
102
+ natGatewayId: route.NatGatewayId,
103
+ transitGatewayId: route.TransitGatewayId,
104
+ localGatewayId: route.LocalGatewayId,
105
+ carrierGatewayId: route.CarrierGatewayId,
106
+ networkInterfaceId: route.NetworkInterfaceId,
107
+ origin: route.Origin!,
108
+ state: route.State!,
109
+ vpcPeeringConnectionId: route.VpcPeeringConnectionId,
110
+ coreNetworkArn: route.CoreNetworkArn,
111
+ })),
112
+ propagatingVgws: routeTable.PropagatingVgws?.map((vgw) => ({
113
+ gatewayId: vgw.GatewayId!,
114
+ })),
115
+ } satisfies RouteTableAttrs<RouteTableProps>;
116
+ }),
117
+
118
+ update: Effect.fn(function* ({ news, olds, output, session }) {
119
+ const routeTableId = output.routeTableId;
120
+
121
+ // Handle tag updates
122
+ if (
123
+ JSON.stringify(news.tags ?? {}) !== JSON.stringify(olds.tags ?? {})
124
+ ) {
125
+ const alchemyTags = tagged(output.routeTableId);
126
+ const userTags = news.tags ?? {};
127
+ const allTags = { ...alchemyTags, ...userTags };
128
+
129
+ // Delete old tags that are no longer present
130
+ const oldTagKeys = Object.keys(olds.tags ?? {});
131
+ const newTagKeys = Object.keys(news.tags ?? {});
132
+ const tagsToDelete = oldTagKeys.filter(
133
+ (key) => !newTagKeys.includes(key),
134
+ );
135
+
136
+ if (tagsToDelete.length > 0) {
137
+ yield* ec2.deleteTags({
138
+ Resources: [routeTableId],
139
+ Tags: tagsToDelete.map((key) => ({ Key: key })),
140
+ });
141
+ }
142
+
143
+ // Create/update tags
144
+ yield* ec2.createTags({
145
+ Resources: [routeTableId],
146
+ Tags: createTagsList(allTags),
147
+ });
148
+
149
+ yield* session.note("Updated tags");
150
+ }
151
+
152
+ // Re-describe to get current state
153
+ const routeTable = yield* describeRouteTable(
154
+ ec2,
155
+ routeTableId,
156
+ session,
157
+ );
158
+
159
+ return {
160
+ ...output,
161
+ associations: routeTable.Associations?.map((assoc) => ({
162
+ main: assoc.Main ?? false,
163
+ routeTableAssociationId: assoc.RouteTableAssociationId,
164
+ routeTableId: assoc.RouteTableId,
165
+ subnetId: assoc.SubnetId,
166
+ gatewayId: assoc.GatewayId,
167
+ associationState: assoc.AssociationState
168
+ ? {
169
+ state: assoc.AssociationState.State!,
170
+ statusMessage: assoc.AssociationState.StatusMessage,
171
+ }
172
+ : undefined,
173
+ })),
174
+ routes: routeTable.Routes?.map((route) => ({
175
+ destinationCidrBlock: route.DestinationCidrBlock,
176
+ destinationIpv6CidrBlock: route.DestinationIpv6CidrBlock,
177
+ destinationPrefixListId: route.DestinationPrefixListId,
178
+ egressOnlyInternetGatewayId: route.EgressOnlyInternetGatewayId,
179
+ gatewayId: route.GatewayId,
180
+ instanceId: route.InstanceId,
181
+ instanceOwnerId: route.InstanceOwnerId,
182
+ natGatewayId: route.NatGatewayId,
183
+ transitGatewayId: route.TransitGatewayId,
184
+ localGatewayId: route.LocalGatewayId,
185
+ carrierGatewayId: route.CarrierGatewayId,
186
+ networkInterfaceId: route.NetworkInterfaceId,
187
+ origin: route.Origin!,
188
+ state: route.State!,
189
+ vpcPeeringConnectionId: route.VpcPeeringConnectionId,
190
+ coreNetworkArn: route.CoreNetworkArn,
191
+ })),
192
+ propagatingVgws: routeTable.PropagatingVgws?.map((vgw) => ({
193
+ gatewayId: vgw.GatewayId!,
194
+ })),
195
+ };
196
+ }),
197
+
198
+ delete: Effect.fn(function* ({ output, session }) {
199
+ const routeTableId = output.routeTableId;
200
+
201
+ yield* session.note(`Deleting route table: ${routeTableId}`);
202
+
203
+ // 1. Attempt to delete route table
204
+ yield* ec2
205
+ .deleteRouteTable({
206
+ RouteTableId: routeTableId,
207
+ DryRun: false,
208
+ })
209
+ .pipe(
210
+ Effect.tapError(Effect.logDebug),
211
+ Effect.catchTag(
212
+ "InvalidRouteTableID.NotFound",
213
+ () => Effect.void,
214
+ ),
215
+ // Retry on dependency violations (associations still being deleted)
216
+ Effect.retry({
217
+ // DependencyViolation means there are still dependent resources
218
+ while: (e) => {
219
+ return e._tag === "DependencyViolation";
220
+ },
221
+ schedule: Schedule.exponential(1000, 1.5).pipe(
222
+ Schedule.intersect(Schedule.recurs(10)), // Try up to 10 times
223
+ Schedule.tapOutput(([, attempt]) =>
224
+ session.note(
225
+ `Waiting for dependencies to clear... (attempt ${attempt + 1})`,
226
+ ),
227
+ ),
228
+ ),
229
+ }),
230
+ );
231
+
232
+ // 2. Wait for route table to be fully deleted
233
+ yield* waitForRouteTableDeleted(ec2, routeTableId, session);
234
+
235
+ yield* session.note(
236
+ `Route table ${routeTableId} deleted successfully`,
237
+ );
238
+ }),
239
+ } satisfies ProviderService<RouteTable>;
240
+ }),
241
+ );
242
+
243
+ /**
244
+ * Describe a route table by ID
245
+ */
246
+ const describeRouteTable = (
247
+ ec2: EC2,
248
+ routeTableId: string,
249
+ _session?: ScopedPlanStatusSession,
250
+ ) =>
251
+ Effect.gen(function* () {
252
+ const result = yield* ec2
253
+ .describeRouteTables({ RouteTableIds: [routeTableId] })
254
+ .pipe(
255
+ Effect.catchTag("InvalidRouteTableID.NotFound", () =>
256
+ Effect.succeed({ RouteTables: [] }),
257
+ ),
258
+ );
259
+
260
+ const routeTable = result.RouteTables?.[0];
261
+ if (!routeTable) {
262
+ return yield* Effect.fail(new Error("Route table not found"));
263
+ }
264
+ return routeTable;
265
+ });
266
+
267
+ /**
268
+ * Wait for route table to be deleted
269
+ */
270
+ const waitForRouteTableDeleted = (
271
+ ec2: EC2,
272
+ routeTableId: string,
273
+ session: ScopedPlanStatusSession,
274
+ ) =>
275
+ Effect.gen(function* () {
276
+ yield* Effect.retry(
277
+ Effect.gen(function* () {
278
+ const result = yield* ec2
279
+ .describeRouteTables({ RouteTableIds: [routeTableId] })
280
+ .pipe(
281
+ Effect.tapError(Effect.logDebug),
282
+ Effect.catchTag("InvalidRouteTableID.NotFound", () =>
283
+ Effect.succeed({ RouteTables: [] }),
284
+ ),
285
+ );
286
+
287
+ if (!result.RouteTables || result.RouteTables.length === 0) {
288
+ return; // Successfully deleted
289
+ }
290
+
291
+ // Still exists, fail to trigger retry
292
+ return yield* Effect.fail(new Error("Route table still exists"));
293
+ }),
294
+ {
295
+ schedule: Schedule.fixed(2000).pipe(
296
+ // Check every 2 seconds
297
+ Schedule.intersect(Schedule.recurs(15)), // Max 30 seconds
298
+ Schedule.tapOutput(([, attempt]) =>
299
+ session.note(
300
+ `Waiting for route table deletion... (${(attempt + 1) * 2}s)`,
301
+ ),
302
+ ),
303
+ ),
304
+ },
305
+ );
306
+ });
@@ -0,0 +1,175 @@
1
+ import type * as EC2 from "itty-aws/ec2";
2
+ import type { Input } from "../../input.ts";
3
+ import { Resource } from "../../resource.ts";
4
+ import type { AccountID } from "../account.ts";
5
+ import type { RegionID } from "../region.ts";
6
+ import type { VpcId } from "./vpc.ts";
7
+
8
+ export const RouteTable = Resource<{
9
+ <const ID extends string, const Props extends RouteTableProps>(
10
+ id: ID,
11
+ props: Props,
12
+ ): RouteTable<ID, Props>;
13
+ }>("AWS.EC2.RouteTable");
14
+
15
+ export interface RouteTable<
16
+ ID extends string = string,
17
+ Props extends RouteTableProps = RouteTableProps,
18
+ > extends Resource<
19
+ "AWS.EC2.RouteTable",
20
+ ID,
21
+ Props,
22
+ RouteTableAttrs<Input.Resolve<Props>>,
23
+ RouteTable
24
+ > {}
25
+
26
+ export type RouteTableId<ID extends string = string> = `rtb-${ID}`;
27
+ export const RouteTableId = <ID extends string>(
28
+ id: ID,
29
+ ): ID & RouteTableId<ID> => `rtb-${id}` as ID & RouteTableId<ID>;
30
+
31
+ export interface RouteTableProps {
32
+ /**
33
+ * The VPC to create the route table in.
34
+ * Required.
35
+ */
36
+ vpcId: Input<VpcId>;
37
+
38
+ /**
39
+ * Tags to assign to the route table.
40
+ * These will be merged with alchemy auto-tags (alchemy::app, alchemy::stage, alchemy::id).
41
+ */
42
+ tags?: Record<string, Input<string>>;
43
+ }
44
+
45
+ export interface RouteTableAttrs<Props extends RouteTableProps> {
46
+ /**
47
+ * The ID of the VPC the route table is in.
48
+ */
49
+ vpcId: Props["vpcId"];
50
+
51
+ /**
52
+ * The ID of the route table.
53
+ */
54
+ routeTableId: RouteTableId;
55
+
56
+ /**
57
+ * The Amazon Resource Name (ARN) of the route table.
58
+ */
59
+ routeTableArn: `arn:aws:ec2:${RegionID}:${AccountID}:route-table/${this["routeTableId"]}`;
60
+
61
+ /**
62
+ * The ID of the AWS account that owns the route table.
63
+ */
64
+ ownerId?: string;
65
+
66
+ /**
67
+ * The associations between the route table and subnets or gateways.
68
+ */
69
+ associations?: Array<{
70
+ /**
71
+ * Whether this is the main route table for the VPC.
72
+ */
73
+ main: boolean;
74
+ /**
75
+ * The ID of the association.
76
+ */
77
+ routeTableAssociationId?: string;
78
+ /**
79
+ * The ID of the route table.
80
+ */
81
+ routeTableId?: string;
82
+ /**
83
+ * The ID of the subnet (if the association is with a subnet).
84
+ */
85
+ subnetId?: string;
86
+ /**
87
+ * The ID of the gateway (if the association is with a gateway).
88
+ */
89
+ gatewayId?: string;
90
+ /**
91
+ * The state of the association.
92
+ */
93
+ associationState?: {
94
+ state: EC2.RouteTableAssociationStateCode;
95
+ statusMessage?: string;
96
+ };
97
+ }>;
98
+
99
+ /**
100
+ * The routes in the route table.
101
+ */
102
+ routes?: Array<{
103
+ /**
104
+ * The IPv4 CIDR block used for the destination match.
105
+ */
106
+ destinationCidrBlock?: string;
107
+ /**
108
+ * The IPv6 CIDR block used for the destination match.
109
+ */
110
+ destinationIpv6CidrBlock?: string;
111
+ /**
112
+ * The prefix of the AWS service.
113
+ */
114
+ destinationPrefixListId?: string;
115
+ /**
116
+ * The ID of the egress-only internet gateway.
117
+ */
118
+ egressOnlyInternetGatewayId?: string;
119
+ /**
120
+ * The ID of the gateway (internet gateway or virtual private gateway).
121
+ */
122
+ gatewayId?: string;
123
+ /**
124
+ * The ID of the NAT instance.
125
+ */
126
+ instanceId?: string;
127
+ /**
128
+ * The ID of AWS account that owns the NAT instance.
129
+ */
130
+ instanceOwnerId?: string;
131
+ /**
132
+ * The ID of the NAT gateway.
133
+ */
134
+ natGatewayId?: string;
135
+ /**
136
+ * The ID of the transit gateway.
137
+ */
138
+ transitGatewayId?: string;
139
+ /**
140
+ * The ID of the local gateway.
141
+ */
142
+ localGatewayId?: string;
143
+ /**
144
+ * The ID of the carrier gateway.
145
+ */
146
+ carrierGatewayId?: string;
147
+ /**
148
+ * The ID of the network interface.
149
+ */
150
+ networkInterfaceId?: string;
151
+ /**
152
+ * Describes how the route was created.
153
+ */
154
+ origin: EC2.RouteOrigin;
155
+ /**
156
+ * The state of the route.
157
+ */
158
+ state: EC2.RouteState;
159
+ /**
160
+ * The ID of the VPC peering connection.
161
+ */
162
+ vpcPeeringConnectionId?: string;
163
+ /**
164
+ * The Amazon Resource Name (ARN) of the core network.
165
+ */
166
+ coreNetworkArn?: string;
167
+ }>;
168
+
169
+ /**
170
+ * Any virtual private gateway (VGW) propagating routes.
171
+ */
172
+ propagatingVgws?: Array<{
173
+ gatewayId: string;
174
+ }>;
175
+ }