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

main
ts 67 lines 2.45 KB
Raw
1 import * as AWS from "@alchemy.run/aws";
2 import { expect } from "@alchemy.run/test";
3 import * as Test from "@alchemy.run/test/Alchemy";
4 import * as lf from "@distilled.cloud/aws/lakeformation";
5 import * as Effect from "effect/Effect";
6
7 const { test } = Test.make({ providers: AWS.providers() });
8
9 const describeResource = (resourceArn: string) =>
10 lf.describeResource({ ResourceArn: resourceArn }).pipe(
11 Effect.map((r) => r.ResourceInfo),
12 Effect.catchTag("EntityNotFoundException", () => Effect.succeed(undefined)),
13 );
14
15 test.provider(
16 "register, update, deregister an S3 location",
17 (stack) =>
18 Effect.gen(function* () {
19 yield* stack.destroy();
20
21 // create — register a bucket with the service-linked role
22 const created = yield* stack.deploy(
23 Effect.gen(function* () {
24 const bucket = yield* AWS.S3.Bucket("LfData", {});
25 const location = yield* AWS.LakeFormation.Resource("LfLocation", {
26 resourceArn: bucket.bucketArn,
27 });
28 return { bucket, location };
29 }),
30 );
31
32 expect(created.location.resourceArn).toEqual(created.bucket.bucketArn);
33 expect(created.location.roleArn).toContain("AWSServiceRoleForLakeFormationDataAccess");
34
35 // out-of-band verification
36 const observed = yield* describeResource(created.location.resourceArn);
37 expect(observed).toBeDefined();
38 expect(observed?.RoleArn).toEqual(created.location.roleArn);
39 expect(observed?.HybridAccessEnabled).toEqual(false);
40
41 // update — enable hybrid access mode
42 const updated = yield* stack.deploy(
43 Effect.gen(function* () {
44 const bucket = yield* AWS.S3.Bucket("LfData", {});
45 const location = yield* AWS.LakeFormation.Resource("LfLocation", {
46 resourceArn: bucket.bucketArn,
47 hybridAccessEnabled: true,
48 });
49 return { bucket, location };
50 }),
51 );
52
53 expect(updated.location.resourceArn).toEqual(created.location.resourceArn);
54 expect(updated.location.hybridAccessEnabled).toEqual(true);
55 const reobserved = yield* describeResource(created.location.resourceArn);
56 expect(reobserved?.HybridAccessEnabled).toEqual(true);
57
58 // delete
59 yield* stack.destroy();
60 const gone = yield* describeResource(created.location.resourceArn);
61 expect(gone).toBeUndefined();
62 }),
63 {
64 tags: ["provider:aws", "provider:aws:lakeformation", "provider:aws:s3", "live"],
65 timeout: 180_000,
66 },
67 );