Terraform Error Missing Argument Windows options ... must be specified

163 views Asked by At

I am trying to run a Terraform file with terraform plan. I run into this error, it is really weird because I am declaring the variables in question in my variables.tf files. I also tried to write them down directly into my main.tf file but I have the same error. Of course commenting those three variables make the Terraform works.

main.tf (I replaced my data with Xs):

[...]
  clone {
    template_uuid = data.vsphere_virtual_machine.XXX.id
    customize {
      windows_options {
        computer_name  = "XXX"
        join_domain = "XX.XX"
        domain_admin_user = "${var.domain_admin_user}"
        domain_admin_password = "${var.domain_admin_password}"
        admin_password = "${var.admin_password}"
        time_zone = xxx
      }
      network_interface {
        ipv4_address = "X.X.X.X"
        ipv4_netmask = XX
        dns_server_list = "${var.dns_list}"
        dns_domain = "${var.domain_name}"
      }
      ipv4_gateway = "X.X.X.X"
    }
  }
}

Error message:

Error: Missing required argument
│
│   with vsphere_virtual_machine.XXX,
│   on main.tf line 31, in resource "vsphere_virtual_machine" "XXX":
│   31:         domain_admin_user = "${var.domain_admin_user}"
│
│ "clone.0.customize.0.windows_options.0.join_domain": all of `clone.0.customize.0.windows_options.0.join_domain,clone.0.customize.0.windows_options.domain_admin_password,clone.0.customize.0.windows_options.domain_admin_user`
│ must be specified
╵
╷
│ Error: Missing required argument
│
│   with vsphere_virtual_machine.XXX,
│   on main.tf line 31, in resource "vsphere_virtual_machine" "XXX":
│   31:         domain_admin_user = "${var.domain_admin_user}"
│
│ "clone.0.customize.0.windows_options.0.domain_admin_password": all of `clone.0.customize.0.windows_options.0.domain_admin_password,clone.0.customize.0.windows_options.join_domain` must be specified
╵
╷
│ Error: Missing required argument
│
│   with vsphere_virtual_machine.XXX,
│   on main.tf line 31, in resource "vsphere_virtual_machine" "XXX":
│   31:         domain_admin_user = "${var.domain_admin_user}"
│
│ "clone.0.customize.0.windows_options.0.domain_admin_user": all of `clone.0.customize.0.windows_options.0.domain_admin_user,clone.0.customize.0.windows_options.join_domain` must be specified
1

There are 1 answers

1
Frank On BEST ANSWER

Setting the version of the vSphere provider to 2.5.1 fixed it for me. https://registry.terraform.io/providers/hashicorp/vsphere/2.5.1

terraform {
  required_providers {
    vsphere = {
      source = "hashicorp/vsphere"
      version = "2.5.1"
    }
  }
}