terraformvcloud-director-rest-api

Terraform Vcloud provider is crashing when using terraform plan


I am trying to automate the deployment of VM's in Vcloud using terraform. The server that I am using doesn't have an internet connection so I had to install terraform and VCD provider offline. Terrafom init worked but when I use terraform plan is crashing... Terraform version: 1.0.11 VCD provider version: 3.2.0(I am using this version because we have vcloud 9.7). This is a testing script, to see if terraform works

terraform {
  required_providers {
    vcd = {
      source = "vmware/vcd"
      version = "3.2.0"
    }
  }
}

provider "vcd" {
    user = "test"
    password = "test"
    url = "https://test/api"
    auth_type = "integrated"
    vdc = "Org1VDC"
    org = "System"
    max_retry_timeout = "60"
    allow_unverified_ssl = "true"
}

resource "vcd_org_user" "my-org-admin" {
  org = "my-org"
  name        = "my-org-admin"
  description = "a new org admin"
  role        = "Organization Administrator"
  password    = "change-me"
}

When I run terraform plan I get the following error:

Error: Plugin did not respond
...
The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ConfigureProvider call. The plugin logs may contain more details
Stack trace from the terraform-provider-vcd_v3.2.0 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xaf3b75]
...
Error: The terraform-provider-vcd_v3.2.0 plugin crashed!

In the logs I can see a lot of DEBUG messages where the provider is trying to connect to github. provider.terraform-provider-vcd_v3.2.0: github.com/vmware/go-vcloud-director/v2/govcd.(*VCDClient).Authenticate(...) And for ERROR messages I only saw 2:

  1. plugin.(*GRPCProvider).ConfigureProvider: error="rpc error: code = Unavailable desc = transport is closing"
  2. Failed to read plugin lock file .terraform/plugins/linux_amd64/lock.json: open .terraform/plugins/linux_amd64/lock.json: no such file or directory

This is the first time when am I am configuring Terraform offline and am using VCD provider. Did I miss something?


Solution

  • I have found the issue. At the URL I was using the IP address of the Vcloud api, and for some reason terraform didn't like that and was causing the crash, after changing to the FQDN, terraform started working again.

    Kind regards