Skip to content

Commit 5dc846f

Browse files
Merge pull request #32 from keachi/data_lazy
data lazy loading isn't a good idea.
2 parents dac9c2c + 92bd720 commit 5dc846f

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ data "vsphere_virtual_machine" "template" {
4545
data "vsphere_tag_category" "category" {
4646
count = var.tags != null ? length(var.tags) : 0
4747
name = keys(var.tags)[count.index]
48-
depends_on = [var.vm_depends_on]
48+
depends_on = [var.tag_depends_on]
4949
}
5050

5151
data "vsphere_tag" "tag" {
5252
count = var.tags != null ? length(var.tags) : 0
5353
name = var.tags[keys(var.tags)[count.index]]
5454
category_id = "${data.vsphere_tag_category.category[count.index].id}"
55-
depends_on = [var.vm_depends_on]
55+
depends_on = [var.tag_depends_on]
5656
}
5757

5858
locals {
@@ -68,7 +68,7 @@ resource "vsphere_virtual_machine" "Linux" {
6868

6969
resource_pool_id = data.vsphere_resource_pool.pool.id
7070
folder = var.vmfolder
71-
tags = data.vsphere_tag.tag[*].id
71+
tags = var.tag_ids != null ? var.tag_ids : data.vsphere_tag.tag[*].id
7272
custom_attributes = var.custom_attributes
7373
annotation = var.annotation
7474
extra_config = var.extra_config
@@ -164,7 +164,7 @@ resource "vsphere_virtual_machine" "Windows" {
164164

165165
resource_pool_id = data.vsphere_resource_pool.pool.id
166166
folder = var.vmfolder
167-
tags = data.vsphere_tag.tag[*].id
167+
tags = var.tag_ids != null ? var.tag_ids : data.vsphere_tag.tag[*].id
168168
custom_attributes = var.custom_attributes
169169
annotation = var.annotation
170170
extra_config = var.extra_config

variables.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,17 @@ variable "vmdns" {
9090

9191
#Global Customization Variables
9292
variable "tags" {
93-
description = "The names of any tags to attach to this resource. They shoud already exist"
93+
description = "The names of any tags to attach to this resource. They must already exist."
9494
type = map
9595
default = null
9696
}
9797

98+
variable "tag_ids" {
99+
description = "The ids of any tags to attach to this resource. They must already exist."
100+
type = list
101+
default = null
102+
}
103+
98104
variable "custom_attributes" {
99105
description = "Map of custom attribute ids to attribute value strings to set for virtual machine."
100106
type = map
@@ -352,3 +358,9 @@ variable "vm_depends_on" {
352358
type = any
353359
default = null
354360
}
361+
362+
variable "tag_depends_on" {
363+
description = "Add any external depend on module here like tag_depends_on = [vsphere_tag.foo.id]"
364+
type = any
365+
default = null
366+
}

0 commit comments

Comments
 (0)