terraform - 无法创建新的 Nutanix VM 并将其分配给项目
问题描述
我正在尝试使用 terraform v0.15.0 在 Nutanix 上创建一台新机器,并将该机器分配给我已经拥有的现有项目(在没有 terraform 的 UI 上创建)。
使用 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"
}
}
}
解决方案
在 Nutanix 支持要求我debug
在 terraform 中使用模式后,我发现了问题。
在调试模式下,我看到 terraform 正在使用无法在Nutanix Elements
.
只能从 中创建带有项目Nutanix Prism
的 VM ,而我使用了Nutanix Elements
提供程序。
使用相同的 terraform将提供程序从 切换Nutanix Elements
到,按预期工作。Nutanix Prism
main.yml
推荐阅读
- python - 如何使用 numpy.matmul 广播其他维度?
- spring - 关于 Spring Boot 消息转换器的困惑
- mysql - 从 MySQL 数据库中获取基于多个电子邮件地址的多条记录
- unity3d - Unity 说“按钮”不是组件,也不是从 Monobehavior 派生的
- gstreamer - 如何使用 gstreamer 在客户端指定 rtsp 身份验证凭据?
- python - 如何通过python在json中对象的特定键/值处写入或附加
- java - 数组索引我们的边界
- node.js - 如何使用车把将键添加为表中的标题?
- android - Android 捕获内部(应用程序)音频
- python - 如何将键、值对附加到以索引值作为键对的空字典中?