|Manuals

Terraform Overview

Cloud Manager integrates with HashiCorp Terraform to provision VDI/DaaS instances through Infrastructure-as-Code. Templates uploaded in the wizard’s Template step are executed by Cloud Manager when deploying instances.

Info

For general Terraform documentation, refer to the HashiCorp Terraform documentation portal.

Template File Structure

Cloud Manager expects the following files in your template:

File Purpose
main.tf Resource definitions (VMs, NICs, disks, IPs)
variables.tf Input variable declarations
outputs.tf Output value definitions — used to pass data from Shared Template to VM Template
schema.json Parameter schema for the Cloud Manager wizard UI
uischema.json UI layout definition for the Parameters step

Cloud Manager uploads these files in the Template step of the model creation wizard. See schema.json and uischema.json Reference for details on the schema files.

VM Template

The VM Template defines the resources for each individual instance. Each time Cloud Manager provisions a new instance from the model, it runs the VM Template with the reserved variable vmname set to the name of that instance — derived from the model’s naming scheme (prefix, digits, start index) and instance count configuration.

You name the VM resource however you like; Cloud Manager identifies the manageable resource through the vmname variable and the Terraform state, not through a specific resource label.

Example — Oracle Cloud Infrastructure (OCI) instance (main.tf):

resource "oci_core_instance" "main" {
  compartment_id      = var.compartment_ocid
  availability_domain = var.availability_domain
  display_name        = var.vmname
  shape               = var.instance_shape

  shape_config {
    ocpus         = var.instance_ocpus
    memory_in_gbs = var.instance_memory_gb
  }

  create_vnic_details {
    subnet_id        = var.subnet_id
    display_name     = "${var.vmname}-vnic"
    assign_public_ip = true
    hostname_label   = lower(replace(var.vmname, "_", "-"))
  }

  source_details {
    source_type = "image"
    source_id   = var.image_ocid
  }

  metadata = {
    admin_password = var.admin_password
  }
}

var.vmname is automatically populated by Cloud Manager at deployment time — it is a reserved variable. See Reserved Variables below.

Do not iterate over instances inside the template — Cloud Manager handles batch provisioning, scaling, and lifecycle management externally and invokes the VM Template per the model’s pool configuration.

Info

Default values for variables in variables.tf are used only for local Terraform testing and validation. Cloud Manager always overrides vmname (and any other variables it manages) with the values derived from the model’s configuration at deployment time.

Shared Template

For deployments where all instances share common infrastructure — Virtual Networks, Subnets, Network Security Groups, Storage Accounts, Route Tables — use a Shared Template. A Shared Template executes only once per model deployment and defines infrastructure shared across all instances. It exposes shared resources to the VM Template through Terraform output blocks, which the VM Template consumes as input variables.

Example — Shared Template outputs.tf (OCI):

output "subnet_id" {
  value = oci_core_subnet.vdi_subnet.id
}

output "compartment_ocid" {
  value = var.compartment_ocid
}

output "availability_domain" {
  value = var.availability_domain
}

Example — VM Template consuming shared outputs (main.tf, OCI):

# Attach the instance's VNIC to the shared subnet
resource "oci_core_instance" "main" {
  compartment_id      = var.compartment_ocid
  availability_domain = var.availability_domain
  display_name        = var.vmname
  shape               = var.instance_shape

  create_vnic_details {
    subnet_id        = var.subnet_id
    display_name     = "${var.vmname}-vnic"
    assign_public_ip = true
  }

  # ... additional configuration
}

The VM Template declares matching input variables (subnet_id, compartment_ocid, availability_domain) and Cloud Manager passes the Shared Template outputs to them automatically at deployment time.

Reserved Variables

The following variable names are reserved by Cloud Manager. Do not expose them in schema.json as user-configurable parameters — Cloud Manager populates them automatically at deployment time, and any value set through the schema will be overridden.

Reserved Variable Description
vmname Name of the instance being provisioned (derived from the model’s naming scheme)
vdi_model, vdi_model_id, vdi_model_name, vdi_model_version Model metadata for the current deployment
vdi_deployment_name, vdi_deployment_number Deployment identifiers
vdi_instances, vdi_instances_count Instance batch metadata for the current deployment
vdi_network_id, vdi_gateways_url Cloud Manager network configuration

Declare any reserved variable you reference in your template inside variables.tf (with no default, or a default for local testing) — Cloud Manager will inject the runtime value. The variable you almost always need is vmname.

Warning

Do not declare any reserved variable as a property in schema.json. The Parameters step would expose it to administrators, and the value entered would be silently overridden by Cloud Manager at deployment time.

Template File Requirements Summary

Requirement Details
VM name The VM resource’s name attribute must use var.vmname (or interpolate it)
Reserved variables Do not expose vmname or any vdi_* variable as a schema.json property
Shared Template Optional — use for infrastructure shared across all instances
schema.json / uischema.json Optional — required only if your template exposes configurable parameters

What’s Next

See Also