variable "networks" {
type = map(object({
networkType = optional(string,"VLAN"),
networkId = number,
cluster = string,
description = optional(string),
tenants = set(string)
}))
default = {}
description = "List of networks (vlans) that should exist"
}
variable "tenants" {
type = map(object({
name = string,
description = string,
}))
default = {}
description = "List of tenants and their required attributes"
}
tenants = {
"testProject" = {
name = "testProject"
description = "Test project"
}
}
networks = {
"testSubnet" = {
networkId = 1234
tenants = []
cluster = "my-cluster-name"
description = "test network"
}
}
cluster = {
"my-cluster-name": "11111111-1111-1111-1111-111111111111"
}
resource "nutanix_subnet" "networks" {
for_each = var.networks
name = each.key
description = each.value.description
vlan_id = each.value.networkId
subnet_type = each.value.networkType
cluster_uuid = var.cluster[each.value.cluster]
}
resource "nutanix_project" "projects" {
for_each = var.tenants
name = each.value.name
description = each.value.description
cluster_uuid = var.cluster["my-cluster-name"]
default_subnet_reference {
uuid = nutanix_subnet.networks["testSubnet"].metadata.uuid
# Have tried both with and without the name value below.. with it not set, the terraform plan output shows name=null
# in its proposed list of changes so I added it in to see what changed. The only difference is that the terraform output
# lists a value rather than null. The same error is still generated
#name = each.value.name
}
}
Debug Output
I have captured full debug logs and can provide them directly to someone if needed however I will not be publishing them on the interwebs.
First run change plan output:
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
+ create
Terraform will perform the following actions:
# nutanix_project.projects["testProject"] will be created
+ resource "nutanix_project" "projects" {
+ api_version = (known after apply)
+ cluster_uuid = "0006237c-7e50-ebfd-2895-00e0ed6aeeb9"
+ description = "Test project"
+ id = (known after apply)
+ is_default = (known after apply)
+ metadata = (known after apply)
+ name = "testProject"
+ owner_reference = (known after apply)
+ project_reference = (known after apply)
+ state = (known after apply)
+ account_reference_list (known after apply)
+ categories {
+ name = "tenant"
+ value = "testProject"
}
+ cluster_reference_list (known after apply)
+ default_environment_reference (known after apply)
+ default_subnet_reference {
+ kind = "subnet"
+ name = "testSubnet"
+ uuid = "1d04b3d7-2733-401a-9709-ee85616969c4"
}
+ environment_reference_list (known after apply)
+ external_network_list (known after apply)
+ external_user_group_reference_list (known after apply)
+ subnet_reference_list (known after apply)
+ tunnel_reference_list (known after apply)
+ user_reference_list (known after apply)
+ vpc_reference_list (known after apply)
}
# nutanix_subnet.networks["testNetwork"] will be created
+ resource "nutanix_subnet" "networks" {
+ api_version = (known after apply)
+ availability_zone_reference = (known after apply)
+ cluster_name = (known after apply)
+ cluster_uuid = "0006237c-7e50-ebfd-2895-00e0ed6aeeb9"
+ default_gateway_ip = (known after apply)
+ description = "A test vlan"
+ dhcp_domain_name_server_list = (known after apply)
+ dhcp_domain_search_list = (known after apply)
+ dhcp_options = (known after apply)
+ dhcp_server_address = (known after apply)
+ dhcp_server_address_port = (known after apply)
+ enable_nat = (known after apply)
+ id = (known after apply)
+ ip_config_pool_list_ranges = (known after apply)
+ is_external = (known after apply)
+ metadata = (known after apply)
+ name = "testNetwork"
+ network_function_chain_reference = (known after apply)
+ owner_reference = (known after apply)
+ prefix_length = (known after apply)
+ project_reference = (known after apply)
+ state = (known after apply)
+ subnet_ip = (known after apply)
+ subnet_type = "VLAN"
+ vlan_id = 1234
+ vpc_reference_uuid = (known after apply)
+ vswitch_name = (known after apply)
+ categories (known after apply)
}
Plan: 2 to add, 0 to change, 0 to destroy.
╷
│ Warning: Disabled Providers: ndb, foundation. Please provide required fields in provider configuration to enable them. Refer docs.
│
│ with provider["registry.terraform.io/nutanix/nutanix"],
│ on providers.tf line 18, in provider "nutanix":
│ 18: provider "nutanix" {
│
Second (and third, fourth, etc) run change plan output:
Terraform used the selected providers to generate the following execution plan. Resource
actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# nutanix_project.projects["testProject"] will be updated in-place
~ resource "nutanix_project" "projects" {
id = "b0a4e17e-fdf3-4e99-b323-b47a75b13ce1"
name = "testProject"
# (8 unchanged attributes hidden)
~ default_subnet_reference {
+ kind = "subnet"
name = null
+ uuid = "1d04b3d7-2733-401a-9709-ee85616969c4"
}
}
Plan: 0 to add, 1 to change, 0 to destroy.
Resulting error
Since terraform's plan on the second run showed a name = null for the default_subnet_reference, I tried setting a name attribute within there however there was no change in behaviour after doing this (other than terraform listing a value against the name in the plan output).
This ultimately generates the error below:
│ Error: error waiting for project(b0a4e17e-fdf3-4e99-b323-b47a75b13ce1) to update: error_detail: , progress_message: update_project
│
│ with nutanix_project.projects["testProject"],
│ on main.tf line 29, in resource "nutanix_project" "projects":
│ 29: resource "nutanix_project" "projects" {
When running terraform with debug logging enabled (TF_LOG=DEBUG), I can see it reporting the following API call/responses:
Nutanix Cluster Information
PC 2024.2
Terraform Version
Terraform v1.9.8 on darwin_arm64
Affected Resource(s)
Terraform Configuration Files
Debug Output
I have captured full debug logs and can provide them directly to someone if needed however I will not be publishing them on the interwebs.
First run change plan output:
Second (and third, fourth, etc) run change plan output:
Resulting error
Since terraform's plan on the second run showed a name = null for the default_subnet_reference, I tried setting a name attribute within there however there was no change in behaviour after doing this (other than terraform listing a value against the name in the plan output). This ultimately generates the error below:
When running terraform with debug logging enabled (TF_LOG=DEBUG), I can see it reporting the following API call/responses:
GET'ing the project
PUT'ing the project
Panic Output
n/a
Expected Behavior
First run should create the project Second run should succeed with no changes
Actual Behavior
First run creates the project successfully. Second run wants to make changes to the project (below) and then generates an error:
Steps to Reproduce
terraform apply
terraform apply
Important Factors
0000 <!---Github Issue number --->