@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 38 lines 1.41 KB
Raw
1 import * as dsql from "@distilled.cloud/aws/dsql";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as AWSBindings from "../AWSBindings.ts";
5 import type { Cluster } from "./Cluster.ts";
6 import { GetVpcEndpointServiceName } from "./GetVpcEndpointServiceName.ts";
7
8 /**
9 * HTTP implementation of {@link GetVpcEndpointServiceName}. At deploy time
10 * it grants `dsql:GetVpcEndpointServiceName` on the cluster to the host
11 * Function; at runtime it calls the DSQL control plane with the Function's
12 * own credentials.
13 */
14 export const GetVpcEndpointServiceNameHttp = Layer.effect(
15 GetVpcEndpointServiceName,
16 Effect.gen(function* () {
17 const bind = yield* AWSBindings.Bind;
18 const op = yield* AWSBindings.withCredentials(dsql.getVpcEndpointServiceName);
19
20 return Effect.fn(function* <R extends Cluster>(cluster: R) {
21 const Identifier = yield* cluster.clusterId;
22 if (!globalThis.__ALCHEMY_RUNTIME__) {
23 yield* bind`AWS.DSQL.GetVpcEndpointServiceName(${cluster})`({
24 policyStatements: [
25 {
26 Effect: "Allow",
27 Action: ["dsql:GetVpcEndpointServiceName"],
28 Resource: [cluster.clusterArn],
29 },
30 ],
31 });
32 }
33 return Effect.fn(`AWS.DSQL.GetVpcEndpointServiceName(${cluster.LogicalId})`)(function* () {
34 return yield* op({ identifier: yield* Identifier });
35 });
36 });
37 }),
38 );