将现有 vsphere 集群导入 terraform 状态

问题描述 投票:0回答:0

我正在尝试将现有的 vxrail 集群导入我的 Terraform 状态。我可以看到集群在那里使用数据块,但是尝试进行导入时我一直无法找到它。我尝试了很多不同的路径,但我仍然无法找到它。

官方文档说

terraform import vsphere_compute_cluster.compute_cluster /dc-01/host/cluster-01

我试过有和没有主机,dc。我已经尝试使用 id,而不是名称,但我仍然无法匹配。

terraform import vsphere_compute_cluster.vxrail "/DATACENTER_NAME/HOSTNAME/vxrail"

terraform import vsphere_compute_cluster.vxrail "/DATACENTER_NAME/vxrail"     
vsphere_compute_cluster.vxrail: Importing from ID "/DATACENTER_NAME/vxrail"...
data.vsphere_compute_cluster.vxrail: Reading...
data.vsphere_compute_cluster.vxrail: Read complete after 0s [id=domain-c1024]
╷
│ Error: error loading cluster: cluster '/DATACENTER_NAME/vxrail' not found
output "private-moid" {
  value = vsphere_datacenter.private.moid
}

output "vxrail" {
  value = data.vsphere_compute_cluster.vxrail
}

data "vsphere_host" "hosts" {
  name          = "bnenxt01-vx57-01.noc.soda.co"
  datacenter_id = vsphere_datacenter.private.moid
}

output "hosts" {
  value = data.vsphere_host.hosts
}

resource "vsphere_compute_cluster" "vxrail" {
  name          = "vxrail"
  datacenter_id = vsphere_datacenter.private.moid
}
terraform vmware vsphere terraform-provider-vsphere
© www.soinside.com 2019 - 2024. All rights reserved.