vmware / terraform-provider-avi

Terraform AVI Networks provider
https://registry.terraform.io/providers/vmware/avi/latest/docs
Mozilla Public License 2.0
31 stars 32 forks source link

Provider should throw an error if unable to create AVI client #604

Open jakauppila opened 3 months ago

jakauppila commented 3 months ago

Describe the bug

If you attempt to utilize the provider but don't define a host or credentials, it continues on despite failing to create an aviClient during provider instantiation.

Reproduction steps

  1. Configure this minimal main.tf Terraform configuration
terraform {
  required_providers {
    avi = {
      source  = "vmware/avi"
      version = "30.2.1"
    }
  }
}

provider "avi" {
  avi_tenant = "admin"
}

data "avi_certificatemanagementprofile" "profile" {
  name = "LetsEncryptCertificateManagementProfile"
}
  1. Terraform init
  2. Terraform apply
  3. Provider attempts to execute on the resources contained within configuration

Debug Logs:

[WARN]  unexpected data: registry.terraform.io/vmware/avi:stderr="E0806 23:08:46.484481   32924 avisession.go:1632] Controller Host is not valid."
[INFO]  provider.terraform-provider-avi_v30.2.1.exe: 2024/08/06 23:08:46 Avi Client created for user admin tenant admin version 18.2.8: timestamp=2024-08-06T23:08:46.487-0500
[DEBUG] Resource instance state not found for node "data.avi_certificatemanagementprofile.profile", instance data.avi_certificatemanagementprofile.profile
[DEBUG] ReferenceTransformer: "data.avi_certificatemanagementprofile.profile" references: []
data.avi_certificatemanagementprofile.profile: Reading...
[INFO]  provider.terraform-provider-avi_v30.2.1.exe: 2024/08/06 23:08:46 [DEBUG] APIRead reading object with objType certificatemanagementprofile id: timestamp=2024-08-06T23:08:46.490-0500
[INFO]  provider.terraform-provider-avi_v30.2.1.exe: 2024/08/06 23:08:46 [DEBUG] APIRead using name LetsEncryptCertificateManagementProfile: timestamp=2024-08-06T23:08:46.490-0500
[WARN]  unexpected data: registry.terraform.io/vmware/avi:stderr="E0806 23:08:46.490035   32924 avisession.go:829] Client error for URI: login. Error: Post \"https:///login\": http: no Host in request URL"
[WARN]  unexpected data: registry.terraform.io/vmware/avi:stderr="E0806 23:08:46.490035   32924 avisession.go:832] Error while dumping request. Still retrying."
[WARN]  unexpected data:
  registry.terraform.io/vmware/avi:stderr=
  | E0806 23:08:46.490035   32924 avisession.go:1173] http: no Host in request URL
  |
  | E0806 23:08:46.490035   32924 avisession.go:1200] CheckControllerStatus Error while generating http request https:////api/cluster/status Get "https:////api/cluster/status": http: no Host in request URL

[WARN]  unexpected data: registry.terraform.io/vmware/avi:stderr="E0806 23:08:49.498390   32924 avisession.go:1210] CheckControllerStatus Controller https:////api/cluster/status Retrying. round 0..!"
[WARN]  unexpected data: registry.terraform.io/vmware/avi:stderr="E0806 23:08:49.498390   32924 avisession.go:1200] CheckControllerStatus Error while generating http request https:////api/cluster/status Get \"https:////api/cluster/status\": http: no Host in request URL"
data.avi_certificatemanagementprofile.profile: Still reading... [10s elapsed]
[WARN]  unexpected data: registry.terraform.io/vmware/avi:stderr="E0806 23:08:57.509506   32924 avisession.go:1210] CheckControllerStatus Controller https:////api/cluster/status Retrying. round 1..!"
[WARN]  unexpected data: registry.terraform.io/vmware/avi:stderr="E0806 23:08:57.509737   32924 avisession.go:1200] CheckControllerStatus Error while generating http request https:////api/cluster/status Get \"https:////api/cluster/status\": http: no Host in request URL"

Expected behavior

Provider should throw an error after it fails to create an aviClient at https://github.com/vmware/terraform-provider-avi/blob/c0466352981468a776b762afa7fc446f8c949cf8/avi/provider.go#L352-L365

Additional context

No response