PrivateNetwork
Source:
src/Railway/PrivateNetwork.ts
A Railway.PrivateNetwork is a named private mesh in an environment.
Every environment already has the default *.railway.internal mesh —
this resource create-or-gets an additional named network (custom DNS)
and is the parent of PrivateNetworkEndpoint.
Railway has no per-network delete. Destroy is a no-op; the network is
removed when its Project/Environment is deleted. create-or-get is
idempotent for a given (environment, name).
Create a named network
Section titled “Create a named network”Pass a Project (or Environment). Alchemy generates a unique name.
dnsName is the network suffix endpoints hang off.
const site = yield* Railway.Project("Site");const net = yield* Railway.PrivateNetwork("Mesh", { environment: site,});A stable name
Section titled “A stable name”Pass name when you need a stable network name. Changing it later
replaces the resource — Railway cannot rename a network.
const net = yield* Railway.PrivateNetwork("Mesh", { environment: site, name: "backend",});Endpoints
Section titled “Endpoints”Attach a Service with a custom DNS name via
PrivateNetworkEndpoint.
const api = yield* Railway.Service("Api", { project: site, image: "hashicorp/http-echo",});const endpoint = yield* Railway.PrivateNetworkEndpoint("ApiDns", { network: net, service: api, name: "api",});Module-scope declarations
Section titled “Module-scope declarations”Resource-valued props accept the resource or an Effect producing it.
import * as Railway from "alchemy/Railway";
export const Site = Railway.Project("Site");export const Mesh = Railway.PrivateNetwork("Mesh", { environment: Site,});