| 1 | import * as GCP from "@/GCP"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import { serveProbes } from "../../bindingHost.ts"; |
| 4 | import { CAPACITY_ZONE } from "../../zones.ts"; |
| 5 | |
| 6 | /** ZONAL instance: snapshots are unsupported on the BASIC tiers. */ |
| 7 | export const ZonalNfs = GCP.Filestore.Instance("ZonalNfs", { |
| 8 | location: CAPACITY_ZONE, |
| 9 | tier: "ZONAL", |
| 10 | fileShares: [{ name: "share1", capacityGb: 1024 }], |
| 11 | }); |
| 12 | |
| 13 | export const Snap = Effect.gen(function* () { |
| 14 | const instance = yield* ZonalNfs; |
| 15 | return yield* GCP.Filestore.InstancesSnapshot("Snap", { |
| 16 | instance: instance.name, |
| 17 | }); |
| 18 | }); |
| 19 | |
| 20 | /** |
| 21 | * Effect-native Cloud Run service exercising the snapshot binding as its own |
| 22 | * runtime service account. Deployed from {@link ../Bindings.test.ts}. |
| 23 | */ |
| 24 | export default class FilestoreSnapshotBindingsHost extends GCP.Function<FilestoreSnapshotBindingsHost>()( |
| 25 | "FilestoreSnapshotBindingsHost", |
| 26 | { main: import.meta.url, invokerIamDisabled: true }, |
| 27 | Effect.gen(function* () { |
| 28 | const getSnapshot = yield* GCP.Filestore.GetInstancesSnapshot(yield* Snap); |
| 29 | |
| 30 | return { |
| 31 | fetch: serveProbes({ |
| 32 | getInstancesSnapshot: getSnapshot(), |
| 33 | }), |
| 34 | }; |
| 35 | }).pipe(Effect.provide(GCP.Filestore.GetInstancesSnapshotHttp)), |
| 36 | ) {} |