forked from unnowataru/terraform-nutanix-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
61 lines (55 loc) · 1.45 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Define Variables
variable "prov_username" {}
variable "prov_password" {}
variable "prov_endpoint" {}
variable "prov_vmname_prefix" {}
variable "prov_num" {}
variable "prov_subnet_uuid" {}
variable "prov_diskimage_uuid" {}
variable "prov_vcpu" {}
variable "prov_sock" {}
variable "prov_mem" {}
# Provider
provider "nutanix" {
username = var.prov_username
password = var.prov_password
endpoint = var.prov_endpoint
insecure = true
port = 9440
}
data "nutanix_clusters" "clusters" {}
locals {
prov_cluster = [
for cluster in data.nutanix_clusters.clusters.entities :
cluster.metadata.uuid if cluster.service_list[0] != "PRISM_CENTRAL"
][0]
}
resource "nutanix_virtual_machine" "nutanix_virtual_machine"{
# General Information
count = var.prov_num
name = "${var.prov_vmname_prefix}${format("%03d",count.index+1)}"
description = "Provisioned by Terraform"
num_vcpus_per_socket = var.prov_vcpu
num_sockets = var.prov_sock
memory_size_mib = var.prov_mem
# Configure Cluster
cluster_uuid = local.prov_cluster
# Configure Network
nic_list {
subnet_uuid = var.prov_subnet_uuid
}
# Configure Disk
disk_list {
data_source_reference = {
kind = "image"
uuid = var.prov_diskimage_uuid
}
device_properties {
disk_address = {
device_index = 0
adapter_type = "SCSI"
}
device_type = "DISK"
}
}
}