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
| 1 | import * as r53r from "@distilled.cloud/aws/route53resolver"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as AWSBindings from "../AWSBindings.ts"; |
| 5 | import { ListResolverRuleAssociations } from "./ListResolverRuleAssociations.ts"; |
| 6 | import type { ResolverRule } from "./ResolverRule.ts"; |
| 7 | |
| 8 | /** |
| 9 | * Bespoke (not via `BindingHttp.ts`): the operation is filter-based rather |
| 10 | * than ID-keyed, so the rule is injected as a `ResolverRuleId` filter instead |
| 11 | * of a request field. The IAM grant is `Resource: "*"` — verified live: |
| 12 | * `route53resolver:ListResolverRuleAssociations` does not support |
| 13 | * resource-level permissions (a rule-ARN-scoped grant is AccessDenied), the |
| 14 | * runtime callable's injected filter is what scopes results to the bound |
| 15 | * rule. The operation also internally describes the associated VPCs, so |
| 16 | * `ec2:DescribeVpcs` is required alongside it (also verified live — without |
| 17 | * it the call fails with `InvalidParameterException: You are not authorized |
| 18 | * to perform this operation ... ec2:DescribeVpcs`). |
| 19 | */ |
| 20 | export const ListResolverRuleAssociationsHttp = Layer.effect( |
| 21 | ListResolverRuleAssociations, |
| 22 | Effect.gen(function* () { |
| 23 | const bind = yield* AWSBindings.Bind; |
| 24 | const op = yield* AWSBindings.withCredentials(r53r.listResolverRuleAssociations); |
| 25 | |
| 26 | return Effect.fn(function* (rule: ResolverRule) { |
| 27 | const ResolverRuleId = yield* rule.resolverRuleId; |
| 28 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 29 | yield* bind`AWS.Route53Resolver.ListResolverRuleAssociations(${rule})`({ |
| 30 | policyStatements: [ |
| 31 | { |
| 32 | Effect: "Allow", |
| 33 | Action: ["route53resolver:ListResolverRuleAssociations", "ec2:DescribeVpcs"], |
| 34 | Resource: ["*"], |
| 35 | }, |
| 36 | ], |
| 37 | }); |
| 38 | } |
| 39 | return Effect.fn(`AWS.Route53Resolver.ListResolverRuleAssociations(${rule.LogicalId})`)( |
| 40 | function* (request?: Omit<r53r.ListResolverRuleAssociationsRequest, "Filters">) { |
| 41 | return yield* op({ |
| 42 | ...request, |
| 43 | Filters: [{ Name: "ResolverRuleId", Values: [yield* ResolverRuleId] }], |
| 44 | }); |
| 45 | }, |
| 46 | ); |
| 47 | }); |
| 48 | }), |
| 49 | ); |