No changes. Your infrastructure matches the configuration

After some changes in main.tf I get the following messages:

$terraform apply 

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no
changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

But I changed my main.tf, How can I apply without above message?

What changes do you think you have made, because Terraform believes the code matches the current state of your infrastructure?

vsphere_virtual_machine_template = "ubuntu16.0.7_64_template"


data "vsphere_virtual_machine" "template" {
  name          = "${var.vsphere_virtual_machine_template}"
  datacenter_id = "${data.vsphere_datacenter.dc.id}"
}


resource "vsphere_virtual_machine" "vmFromLocalOvf" {
  name                       = "majd"
  resource_pool_id           = data.vsphere_resource_pool.pool.id
  datastore_id               = data.vsphere_datastore.datastore.id
  host_system_id             = data.vsphere_host.host.id
  wait_for_guest_net_timeout = 0
  wait_for_guest_ip_timeout  = 0
  datacenter_id              = data.vsphere_datacenter.dc.id
  
  ovf_deploy {
    local_ovf_path       = ""
    disk_provisioning    = "thin"
    ip_protocol          = "IPV4"
    ip_allocation_policy = "STATIC_MANUAL"
    ovf_network_map = {
      "ESX-port-1" = data.vsphere_network.network.id
      "ESX-port-2" = data.vsphere_network.network.id
    }
  }
  vapp {
    properties = {
      "guestinfo.tf.internal.id" = "42"
    }
  }
}

What is the change? Is that totally new code you’ve added? Have you applied anything before? Have you imported any resources?

I have the following tree of .terraform direcory, But when I use terraform init , it tries to get VMware plugin from internet:

# tree .terraform/
.terraform/
β”œβ”€β”€ modules
β”‚   β”œβ”€β”€ example-server-linuxvm
β”‚   β”‚   β”œβ”€β”€ CODE_OF_CONDUCT.md
β”‚   β”‚   β”œβ”€β”€ CONTRIBUTING.md
β”‚   β”‚   β”œβ”€β”€ examples
β”‚   β”‚   β”‚   β”œβ”€β”€ example-linux-depend_on.tf
β”‚   β”‚   β”‚   β”œβ”€β”€ example-linux-Network.tf
β”‚   β”‚   β”‚   β”œβ”€β”€ example-vmname.tf
β”‚   β”‚   β”‚   β”œβ”€β”€ example-Windows-data_disk.tf
β”‚   β”‚   β”‚   └── README.md
β”‚   β”‚   β”œβ”€β”€ LICENSE
β”‚   β”‚   β”œβ”€β”€ main.tf
β”‚   β”‚   β”œβ”€β”€ output.tf
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”œβ”€β”€ tests
β”‚   β”‚   β”‚   β”œβ”€β”€ sanity
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ apply.sh
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ cleanup.sh
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ connection.tf
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ main.tf
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ plan.sh
β”‚   β”‚   β”‚   β”‚   └── README.md
β”‚   β”‚   β”‚   └── smoke
β”‚   β”‚   β”‚       β”œβ”€β”€ apply.sh
β”‚   β”‚   β”‚       β”œβ”€β”€ connection.tf
β”‚   β”‚   β”‚       β”œβ”€β”€ main.tf
β”‚   β”‚   β”‚       β”œβ”€β”€ plan.sh
β”‚   β”‚   β”‚       └── README.md
β”‚   β”‚   β”œβ”€β”€ variables.tf
β”‚   β”‚   └── versions.tf
β”‚   β”œβ”€β”€ example-server-windowsvm-advanced
β”‚   β”‚   β”œβ”€β”€ CODE_OF_CONDUCT.md
β”‚   β”‚   β”œβ”€β”€ CONTRIBUTING.md
β”‚   β”‚   β”œβ”€β”€ examples
β”‚   β”‚   β”‚   β”œβ”€β”€ example-linux-depend_on.tf
β”‚   β”‚   β”‚   β”œβ”€β”€ example-linux-Network.tf
β”‚   β”‚   β”‚   β”œβ”€β”€ example-vmname.tf
β”‚   β”‚   β”‚   β”œβ”€β”€ example-Windows-data_disk.tf
β”‚   β”‚   β”‚   └── README.md
β”‚   β”‚   β”œβ”€β”€ LICENSE
β”‚   β”‚   β”œβ”€β”€ main.tf
β”‚   β”‚   β”œβ”€β”€ output.tf
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   β”œβ”€β”€ tests
β”‚   β”‚   β”‚   β”œβ”€β”€ sanity
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ apply.sh
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ cleanup.sh
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ connection.tf
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ main.tf
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ plan.sh
β”‚   β”‚   β”‚   β”‚   └── README.md
β”‚   β”‚   β”‚   └── smoke
β”‚   β”‚   β”‚       β”œβ”€β”€ apply.sh
β”‚   β”‚   β”‚       β”œβ”€β”€ connection.tf
β”‚   β”‚   β”‚       β”œβ”€β”€ main.tf
β”‚   β”‚   β”‚       β”œβ”€β”€ plan.sh
β”‚   β”‚   β”‚       └── README.md
β”‚   β”‚   β”œβ”€β”€ variables.tf
β”‚   β”‚   └── versions.tf
β”‚   └── modules.json
└── providers
    └── registry.terraform.io
        └── hashicorp
            └── vsphere
                └── 2.0.2
                    └── linux_amd64
                        └── terraform-provider-vsphere_v2.0.2_x5

Hi @mohsen,

I think the most relevant thing for your question here would be to run terraform show to see Terraform’s current record of objects it’s tracking, and then compare that result with your configuration.

Terraform will only propose changes if the configuration is different than the remote objects. β€œNo changes” as you reported earlier is the expected response if your current configuration matches the configuration of the remote objects.

If you can see a difference between the values shown by terraform show and the values your configuration represents (that is, the results of the expressions you wrote) then it would be helpful to share exactly which parts are different.

1 Like

@apparentlymart i am also facing same msg as above explained and i try to create new ec2 and get that error after apply terraform show it shows me β€œstate file is empty. No resources are represented.” what to do now

Hi,

Same problem, Adding new resources on code files.tf but no change with terraform plan.
Any idea?

Thanks in advance