Created
July 10, 2020 14:18
-
-
Save discoposse/a321cb77f96ad8c41123c711c6954938 to your computer and use it in GitHub Desktop.
Terraform vSphere Folder reference challenged when using a Variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vsphere_virtual_machine.vm: Creating... | |
Error: folder '/HawthorneSales/vm/HawthorneSales/vm/Users/eric.wright' not found | |
on main.tf line 1, in resource "vsphere_virtual_machine" "vm": | |
1: resource "vsphere_virtual_machine" "vm" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error: cannot locate folder: folder '/Users/eric.wright' not found | |
on data.tf line 30, in data "vsphere_folder" "folder": | |
30: data "vsphere_folder" "folder" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Datacenter = HawthorneSales | |
Default root folder (hidden) = HawthorneSales/vm | |
Folders = Users/eric.wright |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vsphere_virtual_machine.vm will be created | |
+ resource "vsphere_virtual_machine" "vm" { | |
+ boot_retry_delay = 10000 | |
+ change_version = (known after apply) | |
+ cpu_limit = -1 | |
+ cpu_share_count = (known after apply) | |
+ cpu_share_level = "normal" | |
+ datastore_id = "datastore-1217" | |
+ default_ip_address = (known after apply) | |
+ ept_rvi_mode = "automatic" | |
+ firmware = "bios" | |
+ folder = "Users/eric.wright" | |
+ force_power_off = true | |
+ guest_id = "centos64Guest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# when doing relative path use this | |
export TF_VAR_vsphere_folder='/Users/eric.wright' | |
# when doing absolute path use this | |
export TF_VAR_vsphere_folder='/HawthorneSales/vm/Users/eric.wright' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code works because I explicitly name the folder using a relative path | |
resource "vsphere_virtual_machine" "vm" { | |
name = "web-dev" | |
resource_pool_id = data.vsphere_resource_pool.pool.id | |
datastore_id = data.vsphere_datastore.datastore.id | |
# Use this to enable the variable | |
#folder = "${var.vsphere_folder}" | |
# Use this for explicit path - aka bad idea | |
folder = "/Users/eric.wright" | |
num_cpus = 2 | |
memory = 4096 | |
guest_id = "centos64Guest" | |
wait_for_guest_net_timeout = 0 | |
network_interface { | |
network_id = data.vsphere_network.network.id | |
} | |
disk { | |
label = "disk0" | |
size = 16 | |
thin_provisioned = false | |
} | |
clone { | |
template_uuid = data.vsphere_virtual_machine.template.id | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment