DevOps
Automate Nutanix AHV with Terraform: nutanix/nutanix provider, VM provisioning, categories, and Prism Central infrastructure as code.
LLuca Berton1 min read
On this page
- Provider
- VM with Cloud-Init
- Categories for Policy
- Best Practices
- Frequently asked questions
- What does the Nutanix Terraform provider manage?
- Does the Nutanix provider target Prism Element or Prism Central?
- How do I pass cloud-init to a Nutanix AHV VM?
- How do categories work in Nutanix Terraform?
- Related
Nutanix AHV is the KVM-derived hypervisor that ships with Nutanix HCI. The official nutanix/nutanix Terraform provider drives Prism Central — VMs, categories, projects, images, and self-service blueprints — declaratively.
Provider
terraform {
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "~> 2.0"
}
}
}
provider "nutanix" {
username = var.username
password = var.password
endpoint = var.prism_central_ip
insecure = false
port = 9440
}VM with Cloud-Init
data "nutanix_cluster" "this" { name = "Acme-PROD" }
data "nutanix_subnet" "this" { subnet_name = "vlan-100" }
data "nutanix_image" "ubuntu" { image_name = "ubuntu-24.04-cloud" }
resource "nutanix_virtual_machine" "web" {
name = "web-1"
cluster_uuid = data.nutanix_cluster.this.metadata.uuid
num_vcpus_per_socket = 2
num_sockets = 1
memory_size_mib = 4096
disk_list {
data_source_reference = {
kind = "image"
uuid = data.nutanix_image.ubuntu.id
}
}
nic_list {
subnet_uuid = data.nutanix_subnet.this.metadata.uuid
}
guest_customization_cloud_init_user_data = base64encode(<<-EOT
#cloud-config
hostname: web-1
users:
- name: ubuntu
ssh_authorized_keys:
- ${chomp(file("~/.ssh/id_ed25519.pub"))}
EOT
)
}Categories for Policy
resource "nutanix_category_key" "env" {
name = "Environment"
description = "Deployment environment"
}
resource "nutanix_category_value" "prod" {
name = nutanix_category_key.env.name
value = "Production"
}Best Practices
- Pin VM images — Prism's image library can rotate underneath you.
- Cloud-init user-data over remote-exec — cleaner and faster.
- Categories drive policy in Flow / Calm — model them in Terraform.
- Use Projects to scope multi-team self-service.
Frequently asked questions
What does the Nutanix Terraform provider manage?
The official nutanix/nutanix provider drives Prism Central: virtual machines, images, subnets, categories, projects, access-control policies, and self-service blueprints. It turns the entire Nutanix HCI control plane into declarative infrastructure as code.
Does the Nutanix provider target Prism Element or Prism Central?
Point it at Prism Central (port 9440). Prism Central is the multi-cluster control plane where VMs, categories, and projects live; the provider's v2 resources are built around its v3/v4 APIs rather than the per-cluster Prism Element.
How do I pass cloud-init to a Nutanix AHV VM?
Set guest_customization_cloud_init_user_data on nutanix_virtual_machine to a base64-encoded #cloud-config document. AHV injects it on first boot — use it for hostname, users, SSH keys, and packages instead of remote-exec.
How do categories work in Nutanix Terraform?
Categories are key/value tags (nutanix_category_key + nutanix_category_value) that drive policy in Flow microsegmentation and Calm. Model them in Terraform and attach them to VMs so security and automation policies apply consistently across the fleet.
#Terraform#Nutanix AHV#Prism Central#HCI#Hyperconverged
DevOps
Terraform for Hyper-V Virtualization
Automate Microsoft Hyper-V with Terraform: taliesins/hyperv provider, VM provisioning, virtual switches, and Windows Server-based hypervisor management.
1 min read
DevOps
Terraform for Proxmox VE: Provision Virtual Machines
Provision VMs on Proxmox VE with Terraform using the bpg/proxmox provider: API token auth, cloud-init, LXC containers, and storage pools.
3 min read
DevOps
Terraform for VMware vSphere / ESXi: Complete Guide
Provision VMs on VMware ESXi and vCenter with Terraform: vsphere provider, templates, cloud-init, networking, and resource pools.
3 min read
DevOps
Terraform for Xen and XCP-ng Virtualization
Automate Xen and XCP-ng pools with Terraform: xenorchestra provider, VM provisioning, SR storage, and Citrix Hypervisor lab automation.
1 min read

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.