hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
619 stars 452 forks source link

Error: one of vsphere_server or [deprecated] vcenter_server must be provided #1774

Open dkirrane opened 2 years ago

dkirrane commented 2 years ago

Community Guidelines

Terraform

v1.3.2

Terraform Provider

2.2.0

VMware vSphere

v7.0.3

Description

terraform destroy fails with

│ Error: one of vsphere_server or [deprecated] vcenter_server must be provided
│
│   with provider["registry.terraform.io/hashicorp/vsphere"],
│   on provider.tf line 25, in provider "vsphere":
│   25: provider "vsphere" {

Affected Resources or Data Sources

provider "vsphere" {...}

Terraform Configuration

When the provider uses a datasource to get it's values it fails on terraform destoy

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
╷
│ Error: one of vsphere_server or [deprecated] vcenter_server must be provided
│
│   with provider["registry.terraform.io/hashicorp/vsphere"],
│   on provider.tf line 26, in provider "vsphere":
│   26: provider "vsphere" {

My Terraform config

terraform {
  required_version = ">= 1.3.2"

  required_providers {
    vsphere = {
      source  = "hashicorp/vsphere"
      version = "2.2.0"
    }
    sops = {
      source  = "carlpett/sops"
      version = "0.7.1"
    }
    local = {
      source  = "hashicorp/local"
      version = "2.2.3"
    }
  }
}

provider "sops" {
}

data "sops_file" "credentials" {
  source_file = "${path.root}/credentials.yaml"
}

output "sops_file" {
  value     = nonsensitive(yamlencode(data.sops_file.credentials))
  sensitive = false
}

output "vsphere_server" {
  value     = nonsensitive(tostring(data.sops_file.credentials.data["vsphere_server"]))
  sensitive = false
}

locals {
  vsphere_server              = tostring(data.sops_file.credentials.data["vsphere_server"])
  vsphere_username            = tostring(data.sops_file.credentials.data["vsphere_username"])
  vsphere_password            = tostring(data.sops_file.credentials.data["vsphere_password"])
  vsphere_insecure_connection = tobool(data.sops_file.credentials.data["vsphere_insecure_connection"])
}

provider "vsphere" {
  vsphere_server       = tostring(data.sops_file.credentials.data["vsphere_server"])
  user                 = tostring(data.sops_file.credentials.data["vsphere_username"])
  password             = tostring(data.sops_file.credentials.data["vsphere_password"])
  allow_unverified_ssl = tobool(data.sops_file.credentials.data["vsphere_insecure_connection"])
}

My credentials.yaml (encrypted with sops)

vsphere_server: XXXXX
vsphere_username: XXXXX
vsphere_password: XXXXX
vsphere_insecure_connection: true

Debug Output

2022-10-18T16:44:04.699+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/vsphere/2.2.0/linux_amd64/terraform-provider-vsphere_v2.2.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/vsphere/2.2.0/linux_amd64/terraform-provider-vsphere_v2.2.0_x5]
2022-10-18T16:44:04.705+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/vsphere/2.2.0/linux_amd64/terraform-provider-vsphere_v2.2.0_x5 pid=19294
2022-10-18T16:44:04.705+0100 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/vsphere/2.2.0/linux_amd64/terraform-provider-vsphere_v2.2.0_x5
2022-10-18T16:44:05.421+0100 [INFO]  provider.terraform-provider-vsphere_v2.2.0_x5: configuring server automatic mTLS: timestamp=2022-10-18T16:44:05.421+0100
2022-10-18T16:44:05.486+0100 [DEBUG] provider.terraform-provider-vsphere_v2.2.0_x5: plugin address: address=/tmp/plugin636440397 network=unix timestamp=2022-10-18T16:44:05.486+0100
2022-10-18T16:44:05.486+0100 [DEBUG] provider: using plugin: version=5
2022-10-18T16:44:05.560+0100 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/hashicorp/vsphere\"]" changed the config value, but that value is unused
2022-10-18T16:44:05.561+0100 [ERROR] vertex "provider[\"registry.terraform.io/hashicorp/vsphere\"]" error: one of vsphere_server or [deprecated] vcenter_server must be provided
╷
│ Error: one of vsphere_server or [deprecated] vcenter_server must be provided
│
│   with provider["registry.terraform.io/hashicorp/vsphere"],
│   on provider.tf line 25, in provider "vsphere":
│   25: provider "vsphere" {

Panic Output

No response

Expected Behavior

provider should not error on destroy

Actual Behavior

provider error on destroy

Error: one of vsphere_server or [deprecated] vcenter_server must be provided

Steps to Reproduce

terraform init -upgrade
terraform plan -out my.tfplan
terraform apply my.tfplan
terraform destroy -auto-approve

Environment Details

No response

Screenshots

No response

References

No response

github-actions[bot] commented 2 years ago

Hello, dkirrane! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.