Skip to main content

okustera_compute_instance (Resource)

The okustera_compute_instance resource launches and manages virtual machine instances powered by OpenStack Nova and KVM in Okustera.

Example Usage​

Launch Ubuntu 24.04 VM with Cloud-Init​

data "okustera_image" "ubuntu" {
name = "Ubuntu 24.04 LTS"
}

data "okustera_compute_flavor" "medium" {
name = "m1.medium"
}

resource "okustera_network" "vpc" {
name = "app-network"
cidr = "198.51.100.0/24"
}

resource "okustera_compute_instance" "app_server" {
name = "app-server-01"
flavor_id = data.okustera_compute_flavor.medium.id
image_id = data.okustera_image.ubuntu.id
network_id = okustera_network.vpc.id
key_name = "dev-ssh-key"
security_groups = ["default", "web-tier"]

user_data = <<-EOF
#cloud-config
package_update: true
packages:
- nginx
- curl
EOF
}

output "instance_ip" {
value = okustera_compute_instance.app_server.access_ip_v4
}

Schema​

Required​

  • name (String) Name of the virtual machine instance.
  • flavor_id (String) Nova compute flavor UUID or name.
  • image_id (String) Glance image UUID or name.

Optional​

  • network_id (String) Neutron network UUID to attach the primary interface. Defaults to first available network.
  • key_name (String) Name of the SSH keypair for root login.
  • security_groups (List of String) List of security group names to apply to the instance.
  • user_data (String) Cloud-init script or bootstrap configuration.

Read-Only Attributes​

  • id (String) Virtual machine UUID.
  • status (String) Lifecycle status (e.g. ACTIVE, SHUTOFF, BUILD).
  • access_ip_v4 (String) Primary allocated IPv4 address.
  • created_at (String) Creation timestamp.
  • updated_at (String) Last modification timestamp.

Import​

Existing instances can be imported using their UUID:

terraform import okustera_compute_instance.app_server <instance_uuid>