terraform { required_providers { orbstack = { source = "robertdebock/orbstack" version = "~> 3.0" } cloudinit = { source = "hashicorp/cloudinit" version = "~> 2.0" } } } variable "node_count" { description = "Number of nodes to deploy" type = number default = 3 } variable "name" { description = "Base name for the machines" type = string } variable "distro" { description = "OS distribution" type = string default = "ubuntu" } variable "distro_version" { description = "OS distribution version/codename" type = string default = "noble" } variable "extra_cloud_init_parts" { description = "Additional cloud-init parts to layer on top of the base config" type = list(object({ content = string, content_type = string })) default = [] } data "cloudinit_config" "this" { count = var.node_count part { content_type = "text/cloud-config" content = templatefile("${path.module}/cloud-init-base.yaml", { hostname = "${var.name}-${count.index + 1}" }) } dynamic "part" { for_each = var.extra_cloud_init_parts content { content_type = part.value.content_type content = part.value.content } } } resource "orbstack_machine" "this" { count = var.node_count name = "${var.name}-${count.index + 1}" distro = var.distro region = var.distro_version user_data = data.cloudinit_config.this[count.index].rendered } output "machines" { value = { for m in orbstack_machine.this : m.name => m.ip_address } }