Skip to content

WriteDns

Source: src/Hetzner/WriteDns.ts

Binding that lets runtime code create, update, and delete Hetzner Cloud DNS RRSets.

Authenticates with the ambient HCLOUD_TOKEN. A read-only token is rejected on these methods as Forbidden. The zone is fixed by WriteDns(zone) so calls take no zone id. Provide WriteDnsHttp on the Action / Function Effect.

Mutating RRSet endpoints are asynchronous — they return an action that must reach success before a subsequent read is guaranteed to see the change. Poll with waitForZoneAction.

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

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.WriteDns(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);
yield* dns.setRecordSetRecords("app", "A", {
records: [{ value: "192.0.2.2" }],
});
yield* dns.deleteRecordSet("app", "A");
return created.rrset.id;
});
}).pipe(Effect.provide(Hetzner.WriteDnsHttp)),
);