Skip to content

Unable to run terraform apply against a specific target vsphere_virtual_machine: Error: Provider produced inconsistent final plan #2753

Description

@Yogendiran-Subramanian

Code of Conduct

  • I have read and agree to the Code of Conduct.
  • Vote on this issue by adding a 👍 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

v1.14.0

Terraform Provider

v2.16.1

VMware vSphere

7.0.3.01900

Description

I'm not able to deploy a VM when I use a template's details to fetch the "thin_provisioned" data.

When I initially do the terraform plan, the thin_provisioned is set to true, but when i apply, it goes to false and then in between the apply it changes back to true, throwing the below error

Error: Provider produced inconsistent final plan
│
│ When expanding the plan for module.nameserver[0].vsphere_virtual_machine.cloud_init_instance[0] to include new values learned so far during apply, provider
│ "registry.terraform.io/vmware/vsphere" produced an invalid new value for .disk[0].thin_provisioned: was cty.False, but now cty.True.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

This issue looks exactly like #1125

The terraform configurations I use is also same as the one the issue #1125

Affected Resources or Data Sources

resource/vsphere_virtual_machine

Terraform Configuration

data "vsphere_virtual_machine" "template_info" {
    count = var.ova_url == null ? 1 : 0
    name = var.template_name
    datacenter_id = data.vsphere_datacenter.datacenter.id
}

resource "vsphere_virtual_machine" "cloud_init_instance" {
  count             = var.ova_url == null && var.enable_user_data ? 1 : 0
  name              = var.name
  resource_pool_id  = local.cluster != "standalone" ? data.vsphere_compute_cluster.cluster[0].resource_pool_id : data.vsphere_resource_pool.default[0].id
  host_system_id    = data.vsphere_host.host.id
  datastore_id      = data.vsphere_datastore.datastore.id
  num_cpus          = var.cpu
  memory            = var.memory * 1024
  guest_id          = data.vsphere_virtual_machine.template_info[0].guest_id
  firmware          = data.vsphere_virtual_machine.template_info[0].firmware
  scsi_type         = data.vsphere_virtual_machine.template_info[0].scsi_type

  wait_for_guest_net_timeout = 60
  wait_for_guest_ip_timeout = 60

  dynamic "network_interface" {
    for_each = {
      for idx, net in local.network_names:
      idx => net
    }
    content {
      network_id = data.vsphere_network.subnet_info[network_interface.value].id
    }
  }

  disk {
    label = "disk0"
    size  = var.disk_size
    thin_provisioned = data.vsphere_virtual_machine.template_info[0].disks.0.thin_provisioned
  }

  clone {
    template_uuid = data.vsphere_virtual_machine.template_info[0].id
    timeout = 300
  }
  extra_config = local.user_data_config

  lifecycle {
    ignore_changes = all
  }

}

Debug Output

https://gist.github.com/Yogendiran-Subramanian/292dbe19a8356f3aedbfc8551dae0a19

Error: Provider produced inconsistent final plan

│ When expanding the plan for module.nameserver[0].vsphere_virtual_machine.cloud_init_instance[0] to include new values learned so far during apply, provider
│ "registry.terraform.io/vmware/vsphere" produced an invalid new value for .disk[0].thin_provisioned: was cty.False, but now cty.True.

│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Panic Output

No response

Expected Behavior

A VM should be created with the thin_provisioned config same as the template I used

Actual Behavior

Getting Inconsistent final plan error

Steps to Reproduce

  1. Create a template with thin_provisioned as true
  2. Use that template in data_source, get the thin_provisioned value
  3. Use that value in vsphere_virtual_machine.disk like this "data.vsphere_virtual_machine.template_info[0].disks.0.thin_provisioned"
  4. terraform apply

Environment Details

No response

Screenshots

No response

References

#1125

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions