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

main
ts 55 lines 1.92 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { OriginAccessControl } from "@alchemy.run/aws/CloudFront";
3 import { describe, expect } from "@alchemy.run/test";
4 import * as Test from "@alchemy.run/test/Alchemy";
5 import * as cloudfront from "@distilled.cloud/aws/cloudfront";
6 import * as Provider from "alchemy/Provider";
7 import * as Effect from "effect/Effect";
8 import * as Schedule from "effect/Schedule";
9
10 const { test } = Test.make({ providers: AWS.providers() });
11
12 describe(
13 "AWS.CloudFront.OriginAccessControl",
14 { tags: ["provider:aws", "provider:aws:cloudfront", "live"] },
15 () => {
16 test.provider(
17 "list enumerates the deployed origin access control",
18 (stack) =>
19 Effect.gen(function* () {
20 yield* stack.destroy();
21
22 const deployed = yield* stack.deploy(
23 Effect.gen(function* () {
24 return yield* OriginAccessControl("ListOriginAccessControl", {
25 description: "list",
26 originType: "s3",
27 });
28 }),
29 );
30
31 const provider = yield* Provider.findProvider(OriginAccessControl);
32 const all = yield* provider.list();
33
34 expect(all.some((o) => o.originAccessControlId === deployed.originAccessControlId)).toBe(
35 true,
36 );
37
38 yield* stack.destroy();
39 yield* assertOriginAccessControlDeleted(deployed.originAccessControlId);
40 }),
41 { timeout: 300_000 },
42 );
43 },
44 );
45
46 const assertOriginAccessControlDeleted = (id: string) =>
47 cloudfront.getOriginAccessControlConfig({ Id: id }).pipe(
48 Effect.flatMap(() => Effect.fail(new Error("OriginAccessControlStillExists"))),
49 Effect.catchTag("NoSuchOriginAccessControl", () => Effect.void),
50 Effect.retry({
51 while: (error) =>
52 error instanceof Error && error.message === "OriginAccessControlStillExists",
53 schedule: Schedule.max([Schedule.fixed("5 seconds"), Schedule.recurs(24)]),
54 }),
55 );