Route¶
HtzRoute adds a static route to an existing Hetzner Cloud network. Routes direct traffic destined for a CIDR block to a specific gateway IP within the network.
Type: Hetzner::Networking::Route
Import: @cdk-x/hetzner
Props¶
| Prop | Type | Required | Description |
|---|---|---|---|
networkId |
number \| IResolvable |
✅ | ID of the network to add the route to. Use network.attrNetworkId. |
destination |
string |
✅ | Destination network in CIDR notation (e.g. 10.100.1.0/24). Traffic for this range is forwarded to gateway. |
gateway |
string |
✅ | Gateway IP address within the network. Cannot be the first IP of the network range or 172.31.1.1. |
No attribute getters
HtzRoute has no attr* getters — routes are not referenced by other resources.
Create example¶
- References the network — route is created after the network reaches
CREATE_COMPLETE. - Any traffic destined for
10.100.1.0/24will be forwarded to the gateway. - Must be an IP that already exists within the network range (e.g. a server's private IP).
Cross-resource reference example¶
Route the traffic to the gateway IP of a server on the private network. Since the gateway is specified as a string (not a token), you must know the server's private IP at synthesis time. For dynamic IPs, use a fixed private IP assigned at server creation:
- A default route — all traffic not covered by a more specific route goes to the NAT server at
10.0.1.1.
Destroy behavior¶
The engine calls POST /networks/{networkId}/actions/delete_route to remove the route. Routes have no dependencies so they are deleted early in the reverse topological order.