Skip to content

Vm

A Vm represents a virtual machine instance — an EC2 instance on AWS, a Compute Engine VM on GCP, a Cloud Server on Hetzner, or a Droplet on DigitalOcean. It is the primary compute resource and must be attached to a Vpc network.

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
instanceType InstanceType yes Abstract size: 'micro''8xlarge' or a provider-specific map
image ImageType yes Abstract image: 'ubuntu-22.04' | 'ubuntu-24.04' | 'debian-12' or provider-specific map
network Vpc | string yes Vpc this instance belongs to
subnet Subnet | string no Specific subnet override (auto-selected if omitted)
securityGroups (SecurityGroup | string)[] no Security groups attached to this instance
sshPublicKey string no Public key string for SSH access
sshKey SshKey | string no Reference to an SshKey resource
userData string no Cloud-init / startup script
distributeAcrossAzs boolean no Spread across availability zones (default true)
staticIp StaticIp | string no Reserved public IP attached at create time
import { Vpc, Vm, SecurityGroup } from '@kykucloud/types'
const myVpc = new Vpc({ name: 'my-vpc', cidr: '10.0.0.0/16', region: 'eu-central' })
const webSg = new SecurityGroup({
name: 'web-sg',
ingress: [{ protocol: 'tcp', fromPort: 80, toPort: 80, sources: ['0.0.0.0/0'] }],
})
const server = new Vm({
name: 'web-server',
instanceType: 'medium',
image: 'ubuntu-24.04',
network: myVpc,
securityGroups: [webSg],
sshPublicKey: 'ssh-ed25519 AAAAC3…',
userData: '#!/bin/bash\necho "hello" > /etc/motd',
})
Provider Supported Backend
AWS EC2 (RunInstances)
GCP Compute Engine
Hetzner Cloud Server
DigitalOcean Droplet
  • Immutable properties: network cannot be changed after creation on AWS (can’t move between VPCs). instanceType can be changed (stop + resize) on some providers.
  • Image names: Abstract names like 'ubuntu-24.04' are mapped per provider. Provider-specific maps let you pin exact images.
  • SSH key: On Hetzner and DO, sshPublicKey or sshKey imports the key before provisioning. On GCP, the key is set as project metadata. On AWS, the key is imported as a Key Pair.
  • User data: Cloud-init scripts run on first boot. AWS supports up to 16 KB base64-encoded.
  • Name length: Hetzner 63 chars, GCP 62 chars, DO 255 chars. Deploy prefix adds 9 characters.
  • Distribute across AZs: When true, instances are spread evenly across available zones. On Hetzner this distributes across subnets in different zones.