Placement Group¶
HtzPlacementGroup manages a Hetzner Cloud Placement Group. Placement groups control the physical placement of servers to improve availability — the spread type ensures each server in the group runs on a different physical host.
Type: Hetzner::Compute::PlacementGroup
Import: @cdk-x/hetzner
Props¶
| Prop | Type | Required | Description |
|---|---|---|---|
name |
string |
✅ | Placement group name. Must be unique within the project. |
type |
PlacementGroupType |
✅ | Placement strategy. Create-only — cannot be changed after creation. |
labels |
Record<string, string> |
— | Key/value labels. |
PlacementGroupType enum¶
| Value | Description |
|---|---|
PlacementGroupType.SPREAD |
Each server in the group runs on a different physical host. |
Attribute getters¶
| Getter | Resolves to |
|---|---|
attrPlacementGroupId |
The Hetzner-assigned placement group ID (integer). Use this to attach a server to the group via HtzServer.placementGroupId. |
Create example¶
SPREADis the only supported type. It guarantees servers in the group are placed on different physical hosts.
Cross-resource reference example¶
Attach servers to a placement group so they run on separate physical hosts:
attrPlacementGroupIdproduces a{ ref, attr }token — the engine creates the placement group first, then passes its ID to the server creation request.- Both servers reference the same placement group. Hetzner guarantees they run on different physical hosts.
Update behavior¶
Only name and labels can be updated after creation. The type is a createOnlyProperty — to change the placement strategy, destroy the construct and recreate it.
Destroy behavior¶
The engine calls DELETE /placement_groups/{id}. The placement group is removed. Servers that were part of the group are not affected — they continue running on their current physical host.
Remove servers before destroying
Hetzner requires all servers to be removed from a placement group before it can be deleted. Make sure no servers reference this placement group at destroy time, or destroy those servers first.
See also
- Server — attach servers to a placement group via
placementGroupId - Tokens & Cross-resource References — how
attrPlacementGroupIdresolves at deploy time