Skip to content

Hetzner.IP Address reference

Source: src/Hetzner/FloatingIp.ts

An unassigned Hetzner Cloud Floating IP. Provide type and a homeLocation; Alchemy generates a unique name unless you set name. Assignment to a Server is a separate FloatingIpAssignment resource.

type and homeLocation are immutable — changing either replaces the Floating IP (new address). name, description, labels, and deleteProtection update in place.

Unassigned IPv4 in nbg1

const ip = yield* Hetzner.FloatingIp("public-ip", {
type: "ipv4",
homeLocation: "nbg1",
});

IPv6 with description and labels

const ip = yield* Hetzner.FloatingIp("v6", {
type: "ipv6",
homeLocation: "nbg1",
description: "edge anycast",
labels: { role: "edge" },
});
const ip = yield* Hetzner.FloatingIp("public-ip", {
type: "ipv4",
homeLocation: "nbg1",
name: "public-ip-prod",
description: "production frontend",
labels: { env: "prod" },
});

Source: src/Hetzner/FloatingIpAssignment.ts

Assigns a Hetzner Cloud FloatingIp to a Server. The assignment is existence-only: observe the Floating IP and ensure it is bound to the Server. Changing either reference updates in place (the previous IP is unassigned, then the new pair is assigned).

A Floating IP can be assigned to at most one Server at a time. A Server may hold many Floating IPs. Destroying the assignment unassigns the IP but leaves both the Floating IP and the Server in place.

FloatingIpAssignment: Assigning a Floating IP

Section titled “FloatingIpAssignment: Assigning a Floating IP”

Assign an IPv4 to a Server

const server = yield* Hetzner.Server("web", {
image: "ubuntu-24.04",
serverType: "cx23",
location: "nbg1",
});
const ip = yield* Hetzner.FloatingIp("public-ip", {
type: "ipv4",
homeLocation: "nbg1",
});
const assignment = yield* Hetzner.FloatingIpAssignment("public-ip-web", {
floatingIp: ip,
server,
});

Assign with stub identities

const assignment = yield* Hetzner.FloatingIpAssignment("public-ip-web", {
floatingIp: { id: 123 },
server: { serverId: 42 },
});

Source: src/Hetzner/PrimaryIp.ts

An unassigned Hetzner Cloud Primary IP. Provide type and either a location or a datacenter; Alchemy generates a unique name unless you set name. Assignee wiring is a later resource.

type, location, and datacenter are immutable — changing any of them replaces the Primary IP (new address). name, autoDelete, labels, and deleteProtection update in place.

IPv6 in Nuremberg

const ip = yield* Hetzner.PrimaryIp("web-ipv6", {
type: "ipv6",
location: "nbg1",
});

IPv4 placed by datacenter

const ip = yield* Hetzner.PrimaryIp("web-ipv4", {
type: "ipv4",
datacenter: "nbg1-dc3",
});
const ip = yield* Hetzner.PrimaryIp("mail", {
name: "mail-ipv4",
type: "ipv4",
location: "fsn1",
autoDelete: false,
labels: { role: "mail" },
});