Skip to content

IpAssignment

Source: src/Fly/IpAssignment.ts

A Fly.IpAssignment is an address on an App. A Service publishes ports. Fly’s proxy load-balances {app}.fly.dev across Machines that publish a proxy service.

Identity is the allocated ip. There is no in-place update.

shared_v4 is a shared Anycast IPv4. It is free. This is what you want for fly.dev over IPv4. Yield it next to the Service.

export const PublicIp = Fly.IpAssignment("Shared", {
app: Site,
type: "shared_v4",
});

v6 is a dedicated IPv6. It is free.

export const V6 = Fly.IpAssignment("V6", {
app: Site,
type: "v6",
});

v4 is a billed dedicated IPv4. It may 400 if the org has no quota. Prefer shared_v4 or v6 in tests.

export const Dedicated = Fly.IpAssignment("Dedicated", {
app: Site,
type: "v4",
});

region pins a dedicated address. Shared Anycast ignores it. See Regions for the list of codes.

export const Dedicated = Fly.IpAssignment("Dedicated", {
app: Site,
type: "v4",
region: "iad",
});

serviceName binds the address to a Fly proxy service. Changing it replaces the assignment.

export const PublicIp = Fly.IpAssignment("Shared", {
app: Site,
type: "shared_v4",
serviceName: "http",
});

network is an optional 6PN name. Create-only.

export const Private = Fly.IpAssignment("Private", {
app: Site,
type: "v6",
network: "private",
});

orgSlug defaults to the current token’s org. It is not a replacement key.

export const PublicIp = Fly.IpAssignment("Shared", {
app: Site,
type: "shared_v4",
orgSlug: "my-org",
});

Allocate the address on the same App as the Service. api.url is https://{appName}.fly.dev.

export default Alchemy.Stack(
"MyApp",
{ providers: Fly.providers(), state: Alchemy.localState() },
Effect.gen(function* () {
const api = yield* Api;
const ip = yield* PublicIp;
return { url: api.url, ip: ip.ip };
}),
);