terraform-provider-vcd: Importing an existing UI plugin doesn't work as documented

I am attempting to cutomize the VCD portal by publishing an existing plugin to an organization. However the documented method for doing this doesn’t work. The method is to create an empty vcd_ui_plugin resource, then to import the existing plugin into that resource which can then be manipulated. Attempting to create the empty resource fails because the resource expects to be given the “path” parameter to a zip file containing a new plugin.

Terraform Version

Terraform v1.6.6 on windows_amd64

Affected Resource(s)

  • vdc_ui_plugin

Terraform Configuration Files

resource “vcd_ui_plugin” “my_plugin” { enabled = true }

Debug Output

vcd_ui_plugin.my_plugin: Creating… ╷ │ Error: could not create the UI Plugin: plugin path must not be empty │ │ with vcd_ui_plugin.my_plugin, │ on customize-portal.tf line 3, in resource “vcd_ui_plugin” “my_plugin”: │ 3: resource “vcd_ui_plugin” “my_plugin” { │ ╵

Panic Output

N/A

Expected Behavior

An empty vcd_ui_plugin resource should have been created that I could then import an existing UI plugin into (as described in the vcd_ui_plugin resource documentation).

Actual Behavior

The above error occured.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

User Access rights

N/A

Important Factoids

N/A

References

N/A

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15

Most upvoted comments

@adambarreiro I wasn’t able to test it without count but I’ve seen something interesting on terraform core debug logs (I have three imported vcd_ui_plugin but only one, in this case, is marked to be created:

2024-10-09T10:41:35.703+0200 [DEBUG] expandResourceImports: skipping import address vcd_ui_plugin.dr_plugin[0] already in state
2024-10-09T10:41:35.703+0200 [DEBUG] expandResourceImports: skipping import address vcd_ui_plugin.k8s_plugin[0] already in state
2024-10-09T10:41:35.704+0200 [DEBUG] ReferenceTransformer: "vcd_ui_plugin.dr_plugin[0]" references: []
2024-10-09T10:41:35.704+0200 [DEBUG] ReferenceTransformer: "vcd_ui_plugin.k8s_plugin[0]" references: []
2024-10-09T10:41:35.704+0200 [DEBUG] expandResourceImports: skipping import address vcd_ui_plugin.bck_plugin[0] already in state
2024-10-09T10:41:35.705+0200 [DEBUG] ReferenceTransformer: "vcd_ui_plugin.bck_plugin[0]" references: []
...
2024-10-09T10:41:35.757+0200 [INFO]  provider.terraform-provider-vcd_v3.14.0: 2024/10/09 10:41:35 [DEBUG] UI Plugin no longer exists. Removing from tfstate: timestamp="2024-10-09T10:41:35.757+0200"
2024-10-09T10:41:35.757+0200 [WARN]  Provider "registry.terraform.io/vmware/vcd" produced an unexpected new value for vcd_ui_plugin.dr_plugin[0] during refresh.
      - Root object was present, but now absent

it seems something on provider side

Today I cannot reproduce the issue, I have a correct update in place. Anyway I do not use anymore the local value:

# publish dr plugin
resource "vcd_ui_plugin" "dr_plugin" {
  count = local.dr_plugin != null ? 1 : 0 # only if plugin is found

  enabled    = true
  #tenant_ids = local.dr_org_ids
  tenant_ids = (var.input.dr.required == true
    ? setunion(data.vcd_ui_plugin.dr_plugin[0].tenant_ids, [vcd_org.org.id])
    : setsubtract(data.vcd_ui_plugin.dr_plugin[0].tenant_ids, [vcd_org.org.id])
  )
}

Hi Adam

Thank you for your prompt response.

I have tried doing the import first, but mage the mistake of removing the resource from my code before doing so. Now I’ve done the import with the code in place it works correctly.

Many thanks for your help.

/Jonathan