TargetGroup
A TargetGroup is a logical binding between a Vm and a LoadBalancer. It uses label selectors rather than server IDs — the VM is tagged with a label at creation time, and the load balancer discovers it via the label selector. On AWS this maps to a Target Group, on Hetzner and DigitalOcean to LB target label selectors. GCP does not support TargetGroup — use managed instance groups instead.
Config
Section titled “Config”| Property | Type | Required | Description |
|---|---|---|---|
name |
string |
yes | Unique resource name |
id |
string |
no | Explicit ID (auto-generated UUID if omitted) |
provider |
string |
no | Provider label for multi-provider configs |
tags |
Record<string, string> |
no | Arbitrary key-value metadata |
port |
number |
yes | Target port for traffic |
label |
string |
no | Label selector (defaults to kyku-tg=<id>) |
vm |
Vm | string |
yes | Target VM reference |
lb |
LoadBalancer | string |
yes | Parent LoadBalancer reference |
Example
Section titled “Example”import { Vpc, Vm, LoadBalancer, TargetGroup } from '@kykucloud/types'
const myVpc = new Vpc({ name: 'my-vpc', cidr: '10.0.0.0/16', region: 'eu-central' })
const server = new Vm({ name: 'web', instanceType: 'small', image: 'ubuntu-24.04', network: myVpc,})
const lb = new LoadBalancer({ name: 'web-lb', lbType: 'application', vpc: myVpc, listeners: [{ port: 80, protocol: 'http', targets: [] }],})
const tg = new TargetGroup({ name: 'web-tg', port: 8080, vm: server, lb: lb,})Provider Support
Section titled “Provider Support”| Provider | Supported | Backend |
|---|---|---|
| AWS | ✅ | Target Group (ALB/NLB) |
| GCP | ❌ | Not supported — use managed instance groups |
| Hetzner | ✅ | LB target with label selector |
| DigitalOcean | ✅ | LB target with label selector |
- Label selectors: The
labelproperty defaults tokyku-tg=<resource-id>. The VM’s labels are set from itstagsat creation time. The LB target useslabel_selector: { selector: "kyku-tg=<id>" }to discover the VM. - GCP: TargetGroup throws
UnsupportedFeatureError. Use managed instance groups for GCP traffic distribution. - Hetzner: Do not set
use_private_ip: truewhen using label selectors — the API returns an error. - AWS: Target Groups are a separate resource with health check configuration. The LB listener
targetsarray should reference the TargetGroup or use the label selector pattern. - Circular dependencies: Avoid
TargetGroup ↔ LoadBalancercycles by making only one direction reference the other.