| page_title | cozystack_vminstance Resource - cozystack |
|---|---|
| subcategory | |
| description | A Cozystack virtual machine instance, deployed inside a tenant namespace. The deprecated subnets list is not managed (use networks instead). |
A Cozystack virtual machine instance, deployed inside a tenant namespace. The deprecated subnets list is not managed (use networks instead).
resource "cozystack_vmdisk" "os" {
name = "vm-os"
namespace = "tenant-root"
storage = "20Gi"
source = { image = { name = "ubuntu" } }
}
resource "cozystack_vminstance" "vm" {
name = "vm"
namespace = "tenant-root"
instance_type = "u1.medium"
instance_profile = "ubuntu"
run_strategy = "Always"
disks = [
{ name = cozystack_vmdisk.os.name },
]
external = true
external_ports = [22]
ssh_keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA user@example.com"]
cloud_init = <<-EOT
#cloud-config
packages:
- qemu-guest-agent
EOT
# Addresses appear only once the guest is up, so without waiting they are only
# readable from the apply after the one that created the VM. A guest that exits
# before its address is read keeps the apply waiting until wait_timeout.
wait_for_ready = true
}name(String) VMInstance instance name (metadata.name). Immutable.namespace(String) Tenant namespace the application is created in. Immutable.
cloud_init(String) Cloud-init user data.cloud_init_seed(String) Seed string used to generate the SMBIOS UUID for the VM.cpu_model(String) CPU model exposed inside the VM.disks(Attributes List) Disks to attach. (see below for nested schema)external(Boolean) Enable external access from outside the cluster.external_allow_icmp(Boolean) Accept ICMP traffic to the VM in PortList mode (preserves ping and PMTU discovery).external_method(String) Method to pass through traffic to the VM (PortListorWholeIP).external_ports(List of Number) Ports to forward from outside the cluster.gpus(Attributes List) GPUs to attach (NVIDIA driver requires at least 4 GiB RAM). (see below for nested schema)instance_profile(String) Virtual machine preferences profile.instance_type(String) Virtual machine instance type.networks(Attributes List) Networks to attach the VM to. (see below for nested schema)resources(Attributes) Explicit CPU, memory, and socket configuration. (see below for nested schema)run_strategy(String) Requested running state of the VM instance.wait_for_readywaits for an address under the strategies that start a guest themselves (Always,RerunOnFailure,Once); a guest that exits before its address is read keeps the wait going untilwait_timeout.ssh_keys(List of String) SSH public keys for authentication.wait_for_ready(Boolean) Block on create/update until theReadycondition is true and any server-generated outputs the resource exposes are readable.wait_timeout(String) Maximum time to wait whenwait_for_readyis set (Go duration, e.g.10m). Readiness and outputs share this budget; outputs that never appear leave a warning and their attributes stay null until the next refresh.
chart_version(String) Deployed chart version (status.version).id(String) Synthetic identifier in the formnamespace/name.ip_address(String) Primary IP address of the running guest (from the backing VirtualMachineInstance). Populated once the guest is up — setwait_for_ready = trueto have it available sooner.ip_addresses(List of String) All IP addresses reported on the guest's primary interface.ready(Boolean) Whether the application'sReadycondition is true.uid(String) Server-assigned object UID (metadata.uid). Stable across updates; changes on recreate.
Required:
name(String) Disk name (references acozystack_vmdisk).
Optional:
bus(String) Disk bus type (e.g.sata,virtio).
Required:
name(String) GPU resource name.
Required:
name(String) Network attachment name.
Optional:
cpu(String) Number of CPU cores allocated.memory(String) Amount of memory allocated.sockets(String) Number of CPU sockets (vCPU topology).
Import is supported using the following syntax:
The terraform import command can be used, for example:
# VMInstance instances are imported as "<namespace>/<name>".
terraform import cozystack_vminstance.vm tenant-root/vm