vmware / terraform-provider-tanzu-mission-control

Terraform Provider for VMware Tanzu Mission Control
https://registry.terraform.io/providers/vmware/tanzu-mission-control/latest/docs
Mozilla Public License 2.0
37 stars 33 forks source link

Import a manually attached cluster failing #401

Open dsputnikk opened 6 months ago

dsputnikk commented 6 months ago

Describe the bug

I have cut my teeth on Tanzu and I want to now automate provisioning of clusters via TMC's terraform provider. I understand how to create Terraform for a given resource, and I also understand the basics of Terraform importing.

I can successfully import a cluster I create manually thru TMC, but I have several "legacy" clusters that were attached manually.

This doc

.. specifically states that the import command is compromised of mgmt-cluster-name/provisioner_name/cluster_name.

The cluster I imported successfully which I provisioned thru TMC as a test is supervisor-name/vsphere-namespace/terraform-demo-cluster-1

terraform import tanzu-mission-control_tanzu_kubernetes_cluster.terraform-test-1 mgmt-supervisor/tanzu-simcheck/terraform-test-1 <--- Success

The clusters I've previously manually attached display (in the UI) mgmt-cluster-name = 'attached' and provisioner_name = 'attached'.

tkg-attached-cluster is an example of a cluster I've previously attached and has these displayed in the UI: image

terraform import tanzu-mission-control_tanzu_kubernetes_cluster.attach_cluster_without_apply attached/attached/tkg-attached-cluster <--- Fails

Results in:

tanzu-mission-control_tanzu_kubernetes_cluster.attach_cluster_without_apply: Importing from ID "attached/attached/tkg-attached-cluster"...
╷
│ Error: Couldn't import TKG cluster.
│ Management Cluster Name: attached, Provisioner: attached, Cluster Name: tkg-attached-cluster: get request(v1alpha1/managementclusters/attached/provisioners/attached/tanzukubernetesclusters/tkg-attached-cluster) failed with status : 404 Not Found, response: {"error":"cluster not found tkg-attached-cluster","code":5,"message":"cluster not found tkg-attached-cluster"}

tkg-attached-cluster definitely exists, I see it in the TMC Console.

Reproduction steps

  1. Provision TKG cluster thru kubectl
  2. Manually attach to TMC
  3. Attempt to terraform import
  4. Failure ...

Expected behavior

I expect a successful import like in the first example

Additional context

Importing a cluster from TMC is clearly documented/thought about, but is importing previously attached clusters not supported?

I would prefer not to have to reroll the clusters in order to bring them under Terraform control.

github-actions[bot] commented 1 week ago

'Marking this issue as stale due to inactivity. This helps us focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!'