Terraform: Failed to instantiate provider "registry.terraform.io/-/vsphere"

Created on 17 Aug 2020  ยท  3Comments  ยท  Source: hashicorp/terraform

Terraform Version

Terraform v0.13.0
...

Terraform Configuration Files

``` main.tf
terraform {
required_providers {
vsphere = {
source = "hashicorp/vsphere"
version = "1.22.0"
}
}
}
...
resource "vsphere_virtual_machine" "vm" {
name = var.vm_name
resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
datastore_cluster_id = "${data.vsphere_datastore_cluster.datastore_cluster.id}"
#datastore_id = var.vsphere_datastore
num_cpus = var.vm_cpu
memory = var.vm_memory
guest_id = "${data.vsphere_virtual_machine.template.guest_id}"

scsi_type = "${data.vsphere_virtual_machine.template.scsi_type}"
network_interface {
network_id = "${data.vsphere_network.network.id}"
adapter_type = "${data.vsphere_virtual_machine.template.network_interface_types[0]}"
}
...


### Debug Output


<!--
Full debug output can be obtained by running Terraform with the environment variable `TF_LOG=trace`. Please create a GitHub Gist containing the debug output. Please do _not_ paste the debug output in the issue, since debug output is long.

Debug output may contain sensitive information. Please review it before posting publicly, and if you are concerned feel free to encrypt the files using the HashiCorp security public key.
-->

### Crash Output
<!--
If the console output indicates that Terraform crashed, please share a link to a GitHub Gist containing the output of the `crash.log` file.
-->

$ terraform refresh -lock=false -var-file=$ENV.tfvar -state=/mnt/$ENV/os.tfstate

Error: Could not load plugin

Plugin reinitialization required. Please run "terraform init".

Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be located,
don't satisfy the version constraints, or are otherwise incompatible.

Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints, run "terraform providers".

Failed to instantiate provider "registry.terraform.io/-/vsphere" to obtain
schema: unknown provider "registry.terraform.io/-/vsphere"

ERROR: Job failed: exit code 1
```

Expected Behavior

  • hashicorp/terraform:light should've been able to detect the hashicorp/vsphere plugin

Actual Behavior


Terraform reports init succeeded
Then reports that the vsphere plugin cannot be found

Steps to Reproduce

  1. In a gitlab-ci.yml running hashicorp/terraform:light
  2. terraform init
  3. terraform refresh
  4. Error: Could not load plugin

Additional Context

  • This is being run in a multi stage gitlab-ci. However, when trying to troubleshoot I have tried running the entire process 'init > validate > refresh > plan > apply' in a single stage, with the same results.
  • I've tried running this by installing terraform locally and using the exact same main.tf & .tfvar file, succeeed.

References

bug new

All 3 comments

This looks like you have resources in state which are using the legacy provider name. Once your configuration is fixed, you'll need to run terraform apply to upgrade your state file.

From the 0.13 upgrade guide:

For this upgrade in particular, completing the upgrade will require running terraform apply with Terraform 0.13 after upgrading in order to apply some upgrades to the Terraform state, and we recommend doing that with no other changes pending.

Can you try this and report back?

Hi @alisdair

Yes, erasing the .tfstate and running my whole pipeline again fixed my issue.
Thanks!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rjinski picture rjinski  ยท  3Comments

carl-youngblood picture carl-youngblood  ยท  3Comments

c4milo picture c4milo  ยท  3Comments

shanmugakarna picture shanmugakarna  ยท  3Comments

rjinski picture rjinski  ยท  3Comments