Skip to content

Commit 1e489ab

Browse files
author
Arman Keyoumarsi
committed
Added Depend ON
1 parent 155295e commit 1e489ab

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ locals {
6060

6161
// Cloning a Linux VM from a given template. Note: This is the default option!!
6262
resource "vsphere_virtual_machine" "Linux" {
63-
count = var.is_windows_image != "true" ? var.instances : 0
64-
65-
name = "%{if var.vmnameliteral != ""}${var.vmnameliteral}%{else}${var.vmname}${count.index + 1}${var.vmnamesuffix}%{endif}"
63+
count = var.is_windows_image != "true" ? var.instances : 0
64+
depends_on = [var.vm_depends_on]
65+
name = "%{if var.vmnameliteral != ""}${var.vmnameliteral}%{else}${var.vmname}${count.index + 1}${var.vmnamesuffix}%{endif}"
6666

6767
resource_pool_id = data.vsphere_resource_pool.pool.id
6868
folder = var.vmfolder
@@ -153,9 +153,9 @@ resource "vsphere_virtual_machine" "Linux" {
153153
}
154154

155155
resource "vsphere_virtual_machine" "Windows" {
156-
count = var.is_windows_image == "true" ? var.instances : 0
157-
158-
name = "%{if var.vmnameliteral != ""}${var.vmnameliteral}%{else}${var.vmname}${count.index + 1}${var.vmnamesuffix}%{endif}"
156+
count = var.is_windows_image == "true" ? var.instances : 0
157+
depends_on = [var.vm_depends_on]
158+
name = "%{if var.vmnameliteral != ""}${var.vmnameliteral}%{else}${var.vmname}${count.index + 1}${var.vmnamesuffix}%{endif}"
159159

160160
resource_pool_id = data.vsphere_resource_pool.pool.id
161161
folder = var.vmfolder

variables.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ variable "data_disk_size_gb" {
168168
default = []
169169
}
170170

171-
variable "disk_datastore"{
171+
variable "disk_datastore" {
172172
description = "Define where the OS disk should be stored"
173173
type = string
174174
default = ""
@@ -199,7 +199,7 @@ variable "scsi_type" {
199199
default = ""
200200
}
201201

202-
variable "scsi_controller"{
202+
variable "scsi_controller" {
203203
description = "scsi_controller number for the main OS disk"
204204
type = number
205205
default = 0
@@ -228,8 +228,8 @@ variable "enable_disk_uuid" {
228228

229229
variable "network_type" {
230230
description = "Define network type for each network interface"
231-
type = list
232-
default = null
231+
type = list
232+
default = null
233233
}
234234

235235
#Linux Customization Variables
@@ -328,3 +328,9 @@ variable "wait_for_guest_net_timeout" {
328328
default = 5
329329
type = number
330330
}
331+
332+
variable "vm_depends_on" {
333+
description = "Add any external depend on module here like vm_depends_on = [module.fw_core01.firewall]"
334+
type = any
335+
default = null
336+
}

0 commit comments

Comments
 (0)