我试图用terraformv0.15.0在Nutanix上创建一台新机器,并将机器分配给我已经拥有的现有项目(在UI上创建,没有terraform)。
使用Nutanix (https://registry.terraform.io/providers/nutanix/nutanix/latest/docs/resources/virtual_machine#project_reference),我能够创建一个VM,但没有将它分配给现有的项目。但是,使用此main.tf工作,取消对project_reference属性的注释将导致以下错误:
nutanix_virtual_machine.vm1[0]: Creating...
Error: error: {
"api_version": "3.1",
"code": 422,
"message_list": [
{
"details": {
"metadata": [
"Additional properties are not allowed (u'project_reference' was unexpected)"
]
},
"message": "Request could not be processed.",
"reason": "INVALID_REQUEST"
}
],
"state": "ERROR"
}
on main.tf line 67, in resource "nutanix_virtual_machine" "vm1":
67: resource "nutanix_virtual_machine" "vm1" {这是我的密码:
provider "nutanix" {
username = "user"
password = "pass"
port = 1234
endpoint = "ip"
insecure = true
wait_timeout = 10
}
data "nutanix_cluster" "cluster" {
name = "NTNXCluster"
}
data "nutanix_image" "ubuntu-clone" {
image_name = "Ubuntu-20.04-Server"
}
variable "counter" {
type = number
default = 1
}
resource "nutanix_virtual_machine" "vm1" {
name = "test-${count.index+1}"
count = var.counter
description = "desc"
num_vcpus_per_socket = 2
num_sockets = 2
memory_size_mib = 4096
guest_customization_sysprep = {}
cluster_uuid = "my_uuid"
nic_list {
subnet_uuid = "my_uuid"
}
#project_reference = {
# kind = "project"
# uuid = "my_uuid"
# name = "my_project"
#}
disk_list {
data_source_reference = {
kind = "image"
uuid = data.nutanix_image.ubuntu-clone.id
}
device_properties {
disk_address = {
device_index = 0
adapter_type = "SATA"
}
device_type = "DISK"
}
}
}发布于 2021-11-22 20:14:22
在Nutanix支持让我在terraform中使用debug模式后,我发现了这个问题。
在调试模式中,我看到terraform使用的是无法在Nutanix Elements上使用的API调用。
使用项目创建VM 只能通过Nutanix Prism完成,而我使用的是Nutanix Elements提供程序。
将提供者从Nutanix Elements切换到Nutanix Prism,使用相同的terraform main.yml,就像预期的那样。
发布于 2021-11-04 22:17:57
使用:
project_reference = {
kind = "project"
uuid = your_id
}将项目名称从块中删除,使用ID就足够了。
https://stackoverflow.com/questions/69175156
复制相似问题