@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 34 lines 1.25 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import * as Cloudflare from "@alchemy.run/cloudflare";
3 import * as Effect from "effect/Effect";
4 import { ConnectorSecurityGroup, Network } from "./Database.ts";
5
6 /** The Cloudflare Tunnel that carries Hyperdrive's traffic into the VPC. */
7 export const Tunnel = Cloudflare.Tunnel.Tunnel("Tunnel", {
8 ingress: [{ service: "http_status:404" }],
9 });
10
11 /**
12 * Runs `cloudflared` inside the VPC on ECS Fargate. It dials out to
13 * Cloudflare, so the VPC needs no inbound rules. The tunnel token is kept in
14 * Secrets Manager and injected as `TUNNEL_TOKEN`.
15 */
16 export const Connector = Effect.gen(function* () {
17 const network = yield* Network;
18 const securityGroup = yield* ConnectorSecurityGroup;
19 const tunnel = yield* Tunnel;
20 const token = yield* AWS.SecretsManager.Secret("TunnelToken", {
21 secretString: tunnel.token,
22 });
23 const cluster = yield* AWS.ECS.Cluster("Cluster", {});
24 return yield* AWS.ECS.Service("Cloudflared", {
25 cluster,
26 image: "cloudflare/cloudflared:latest",
27 command: ["tunnel", "--no-autoupdate", "run"],
28 secrets: { TUNNEL_TOKEN: token.secretArn },
29 vpcId: network.vpcId,
30 subnets: network.publicSubnetIds,
31 securityGroups: [securityGroup.groupId],
32 assignPublicIp: true,
33 });
34 });