The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import { Bucket } from "@alchemy.run/aws/S3"; |
| 3 | import { MultiRegionAccessPoint } from "@alchemy.run/aws/S3Control"; |
| 4 | import { expect } from "@alchemy.run/test"; |
| 5 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 6 | import { Region } from "@distilled.cloud/aws/Region"; |
| 7 | import * as s3control from "@distilled.cloud/aws/s3-control"; |
| 8 | import * as Effect from "effect/Effect"; |
| 9 | |
| 10 | const { test } = Test.make({ providers: AWS.providers() }); |
| 11 | |
| 12 | const ACCOUNT_ID = "391965393224"; |
| 13 | |
| 14 | // Multi-Region Access Point control-plane requests route through us-west-2. |
| 15 | const findMrap = (name: string) => |
| 16 | s3control.getMultiRegionAccessPoint({ AccountId: ACCOUNT_ID, Name: name }).pipe( |
| 17 | Effect.map((r) => r.AccessPoint), |
| 18 | Effect.catchTag("NoSuchMultiRegionAccessPoint", () => Effect.succeed(undefined)), |
| 19 | Effect.provideService(Region, Effect.succeed("us-west-2")), |
| 20 | ); |
| 21 | |
| 22 | test.provider( |
| 23 | "typed NoSuchMultiRegionAccessPoint tag on a nonexistent access point", |
| 24 | () => |
| 25 | Effect.gen(function* () { |
| 26 | const result = yield* s3control |
| 27 | .getMultiRegionAccessPoint({ |
| 28 | AccountId: ACCOUNT_ID, |
| 29 | Name: "alchemy-does-not-exist-xyz", |
| 30 | }) |
| 31 | .pipe( |
| 32 | Effect.map(() => "found" as const), |
| 33 | // proves the patched typed union — no cast, no catch-all |
| 34 | Effect.catchTag("NoSuchMultiRegionAccessPoint", () => Effect.succeed("missing" as const)), |
| 35 | Effect.provideService(Region, Effect.succeed("us-west-2")), |
| 36 | ); |
| 37 | expect(result).toBe("missing"); |
| 38 | }), |
| 39 | { tags: ["provider:aws", "provider:aws:s3control", "live"], timeout: 60_000 }, |
| 40 | ); |
| 41 | |
| 42 | // Multi-Region Access Point provisioning is asynchronous and can consume the |
| 43 | // entire 240s suite ceiling, so the full lifecycle remains explicitly gated. |
| 44 | test.provider.skipIf(!!process.env.FAST)( |
| 45 | "create and delete multi-region access point (slow, gated)", |
| 46 | (stack) => |
| 47 | Effect.gen(function* () { |
| 48 | yield* stack.destroy(); |
| 49 | |
| 50 | const deployed = yield* stack.deploy( |
| 51 | Effect.gen(function* () { |
| 52 | const bucket = yield* Bucket("MrapBucket", { forceDestroy: true }); |
| 53 | const mrap = yield* MultiRegionAccessPoint("TestMrap", { |
| 54 | regions: [{ bucket: bucket.bucketName }], |
| 55 | }); |
| 56 | return { bucket, mrap }; |
| 57 | }), |
| 58 | ); |
| 59 | |
| 60 | expect(deployed.mrap.multiRegionAccessPointName).toBeDefined(); |
| 61 | expect(deployed.mrap.status).toBe("READY"); |
| 62 | expect(deployed.mrap.alias).toBeDefined(); |
| 63 | expect(deployed.mrap.multiRegionAccessPointArn).toBe( |
| 64 | `arn:aws:s3::${ACCOUNT_ID}:accesspoint/${deployed.mrap.alias}`, |
| 65 | ); |
| 66 | |
| 67 | // out-of-band verification via distilled |
| 68 | const live = yield* findMrap(deployed.mrap.multiRegionAccessPointName); |
| 69 | expect(live?.Status).toBe("READY"); |
| 70 | expect(live?.Regions?.[0]?.Bucket).toBe(deployed.bucket.bucketName); |
| 71 | |
| 72 | yield* stack.destroy(); |
| 73 | |
| 74 | const afterDestroy = yield* findMrap(deployed.mrap.multiRegionAccessPointName); |
| 75 | expect(afterDestroy).toBeUndefined(); |
| 76 | }), |
| 77 | { |
| 78 | tags: ["provider:aws", "provider:aws:s3", "provider:aws:s3control", "live"], |
| 79 | timeout: 240_000, |
| 80 | }, |
| 81 | ); |