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 { DBParameterGroup } from "@alchemy.run/aws/Neptune"; |
| 3 | import { expect } from "@alchemy.run/test"; |
| 4 | import * as Test from "@alchemy.run/test/Alchemy"; |
| 5 | import * as neptune from "@distilled.cloud/aws/neptune"; |
| 6 | import * as Effect from "effect/Effect"; |
| 7 | import * as Schedule from "effect/Schedule"; |
| 8 | import * as Stream from "effect/Stream"; |
| 9 | |
| 10 | const { test } = Test.make({ providers: AWS.providers() }); |
| 11 | |
| 12 | const assertGone = (name: string) => |
| 13 | neptune.describeDBParameterGroups({ DBParameterGroupName: name }).pipe( |
| 14 | Effect.flatMap(() => Effect.fail(new Error(`parameter group '${name}' still exists`))), |
| 15 | Effect.catchTag("DBParameterGroupNotFoundFault", () => Effect.void), |
| 16 | Effect.retry({ |
| 17 | schedule: Schedule.max([Schedule.fixed("2 seconds"), Schedule.recurs(10)]), |
| 18 | }), |
| 19 | ); |
| 20 | |
| 21 | const readUserParameters = (name: string) => |
| 22 | neptune.describeDBParameters.pages({ DBParameterGroupName: name, Source: "user" }).pipe( |
| 23 | Stream.runCollect, |
| 24 | Effect.map((chunk) => Array.from(chunk).flatMap((page) => page.Parameters ?? [])), |
| 25 | ); |
| 26 | |
| 27 | test.provider( |
| 28 | "create, modify parameters, reset, delete a Neptune DB parameter group", |
| 29 | (stack) => |
| 30 | Effect.gen(function* () { |
| 31 | yield* stack.destroy(); |
| 32 | |
| 33 | const { group } = yield* stack.deploy( |
| 34 | Effect.gen(function* () { |
| 35 | const group = yield* DBParameterGroup("InstanceParams", { |
| 36 | family: "neptune1.4", |
| 37 | description: "alchemy neptune instance params", |
| 38 | parameters: { neptune_query_timeout: "180000" }, |
| 39 | tags: { fixture: "neptune-instance-params" }, |
| 40 | }); |
| 41 | return { group }; |
| 42 | }), |
| 43 | ); |
| 44 | |
| 45 | expect(group.dbParameterGroupName).toBeDefined(); |
| 46 | expect(group.dbParameterGroupArn).toContain(":pg:"); |
| 47 | expect(group.family).toBe("neptune1.4"); |
| 48 | expect(group.parameters).toEqual({ neptune_query_timeout: "180000" }); |
| 49 | |
| 50 | // Out-of-band verification: the override is recorded as a user param. |
| 51 | const userParams = yield* readUserParameters(group.dbParameterGroupName); |
| 52 | expect( |
| 53 | userParams.find((p) => p.ParameterName === "neptune_query_timeout")?.ParameterValue, |
| 54 | ).toBe("180000"); |
| 55 | |
| 56 | // Update the parameter value in place. |
| 57 | const { group: updated } = yield* stack.deploy( |
| 58 | Effect.gen(function* () { |
| 59 | const group = yield* DBParameterGroup("InstanceParams", { |
| 60 | family: "neptune1.4", |
| 61 | description: "alchemy neptune instance params", |
| 62 | parameters: { neptune_query_timeout: "60000" }, |
| 63 | tags: { fixture: "neptune-instance-params" }, |
| 64 | }); |
| 65 | return { group }; |
| 66 | }), |
| 67 | ); |
| 68 | expect(updated.dbParameterGroupName).toBe(group.dbParameterGroupName); |
| 69 | const updatedParams = yield* readUserParameters(group.dbParameterGroupName); |
| 70 | expect( |
| 71 | updatedParams.find((p) => p.ParameterName === "neptune_query_timeout")?.ParameterValue, |
| 72 | ).toBe("60000"); |
| 73 | |
| 74 | // Remove the override — the provider resets it to the engine default. |
| 75 | yield* stack.deploy( |
| 76 | Effect.gen(function* () { |
| 77 | const group = yield* DBParameterGroup("InstanceParams", { |
| 78 | family: "neptune1.4", |
| 79 | description: "alchemy neptune instance params", |
| 80 | tags: { fixture: "neptune-instance-params" }, |
| 81 | }); |
| 82 | return { group }; |
| 83 | }), |
| 84 | ); |
| 85 | const resetParams = yield* readUserParameters(group.dbParameterGroupName); |
| 86 | expect(resetParams.find((p) => p.ParameterName === "neptune_query_timeout")).toBeUndefined(); |
| 87 | |
| 88 | yield* stack.destroy(); |
| 89 | yield* assertGone(group.dbParameterGroupName); |
| 90 | }), |
| 91 | { tags: ["provider:aws", "provider:aws:neptune", "live"], timeout: 240_000 }, |
| 92 | ); |