Just starting out with Terraform and I’ve setup a configuration file below.
If I run terraform plan
it returns Terraform has compared your real infrastructure against your configuration and found no differences, so
no changes are needed.
The VMs listed in the configuration file do not exist inside of environment. How can I get Terraform to detect the needed changes?
terraform {
required_providers {
vsphere = {
source = "hashicorp/vsphere"
version = "2.0.2"
}
}
}
provider "vsphere" {
data "vsphere_datacenter" "dc" {
name = "HomeLab"
}
data "vsphere_datastore" "datastore" {
name = "LocalStorage"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
data "vsphere_compute_cluster" "cluster" {
name = "Infrastructure"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
data "vsphere_network" "network" {
name = "VM Network"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
resource "vsphere_virtual_machine" "vmvm01" {
name = "test01"
resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
datastore_id = "${data.vsphere_datastore.datastore.id}"
num_cpus = 2
memory = 8192
guest_id = "ubuntu64Guest"
network_interface {
network_id = "${data.vsphere_network.network.id}"
}
disk {
label = "disk0"
size = 60
}
}
resource "vsphere_virtual_machine" "vm02" {
name = "test02"
resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
datastore_id = "${data.vsphere_datastore.datastore.id}"
num_cpus = 2
memory = 8192
guest_id = "ubuntu64Guest"
network_interface {
network_id = "${data.vsphere_network.network.id}"
}
disk {
label = "disk0"
size = 60
}
}
resource "vsphere_virtual_machine" "vm03" {
name = "test03"
resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
datastore_id = "${data.vsphere_datastore.datastore.id}"
num_cpus = 2
memory = 8192
guest_id = "ubuntu64Guest"
network_interface {
network_id = "${data.vsphere_network.network.id}"
}
disk {
label = "disk0"
size = 60
}
}
resource "vsphere_virtual_machine" "vm04" {
name = "test04"
resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
datastore_id = "${data.vsphere_datastore.datastore.id}"
num_cpus = 2
memory = 8192
guest_id = "ubuntu64Guest"
network_interface {
network_id = "${data.vsphere_network.network.id}"
}
disk {
label = "disk0"
size = 60
}
}
}