The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { RouteTable, RouteTableAssociation, Subnet, Vpc } from "@alchemy.run/aws/EC2"; |
| 3 | import { expect } from "@alchemy.run/test"; |
| 4 | import * as Provider from "alchemy/Provider"; |
| 5 | import * as Effect from "effect/Effect"; |
| 6 | import { MinimumLogLevel } from "effect/References"; |
| 7 | import { assertVpcGone } from "./Gone.ts"; |
| 8 | import * as Test from "./VpcTest.ts"; |
| 9 | |
| 10 | const { test } = Test.make({ providers: AWS.providers() }); |
| 11 | |
| 12 | const logLevel = Effect.provideService(MinimumLogLevel, process.env.DEBUG ? "Debug" : "Info"); |
| 13 | |
| 14 | test.provider( |
| 15 | "list enumerates the deployed RouteTableAssociation", |
| 16 | (stack) => |
| 17 | Effect.gen(function* () { |
| 18 | yield* stack.destroy(); |
| 19 | |
| 20 | const { vpc, assoc } = yield* stack.deploy( |
| 21 | Effect.gen(function* () { |
| 22 | const vpc = yield* Vpc("ListRtbAssocVpc", { |
| 23 | cidrBlock: "10.0.0.0/16", |
| 24 | }); |
| 25 | const subnet = yield* Subnet("ListRtbAssocSubnet", { |
| 26 | vpcId: vpc.vpcId, |
| 27 | cidrBlock: "10.0.1.0/24", |
| 28 | }); |
| 29 | const routeTable = yield* RouteTable("ListRtbAssocRt", { |
| 30 | vpcId: vpc.vpcId, |
| 31 | }); |
| 32 | const assoc = yield* RouteTableAssociation("ListRtbAssoc", { |
| 33 | routeTableId: routeTable.routeTableId, |
| 34 | subnetId: subnet.subnetId, |
| 35 | }); |
| 36 | return { vpc, subnet, routeTable, assoc }; |
| 37 | }), |
| 38 | ); |
| 39 | |
| 40 | const provider = yield* Provider.findProvider(RouteTableAssociation); |
| 41 | const all = yield* provider.list(); |
| 42 | |
| 43 | expect(all.some((x) => x.associationId === assoc.associationId)).toBe(true); |
| 44 | |
| 45 | yield* stack.destroy(); |
| 46 | |
| 47 | // The VPC cannot delete while the subnet/route-table/association exist — |
| 48 | // VPC-gone proves full teardown. |
| 49 | yield* assertVpcGone(vpc.vpcId); |
| 50 | }).pipe(logLevel), |
| 51 | { tags: ["provider:aws", "provider:aws:ec2", "live"] }, |
| 52 | ); |