Skip to content

ReadWriteDns

Source: src/Hetzner/ReadWriteDns.ts

Binding that lets runtime code perform the full Hetzner Cloud DNS RRSet surface (read + write).

Authenticates with the ambient HCLOUD_TOKEN. The zone is fixed by ReadWriteDns(zone) so calls take no zone id. Provide ReadWriteDnsHttp on the Action / Function Effect.

Bind the client in the Action’s Init phase and provide ReadWriteDnsHttp.

import * as Alchemy from "alchemy";
import * as Hetzner from "alchemy/Hetzner";
import * as Effect from "effect/Effect";
const Seed = Alchemy.Action(
"Seed",
Effect.gen(function* () {
const dns = yield* Hetzner.ReadWriteDns(zone);
return Effect.fn(function* () {
const created = yield* dns.createRecordSet({
name: "app",
type: "A",
records: [{ value: "192.0.2.1" }],
ttl: 300,
});
yield* Hetzner.waitForZoneAction(created.action);
const rrset = yield* dns.getRecordSet("app", "A");
yield* dns.deleteRecordSet("app", "A");
return rrset.rrset.id;
});
}).pipe(Effect.provide(Hetzner.ReadWriteDnsHttp)),
);