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.