Skip to content

Commit ef0befb

Browse files
committed
Do not set fqdn if zone is missing
1 parent a1baf5f commit ef0befb

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

netbox/vm/main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
locals {
2-
domain = try(trimsuffix(var.zone.dns_name, "."), "local")
3-
fqdn = "${var.name}.${local.domain}"
2+
fqdn = var.zone != null ? "${var.name}.${trimsuffix(var.zone.dns_name, ".")}" : null
43
ip_address = var.ip_address != null ? split("/", var.ip_address)[0] : null
54
ip_prefix = var.ip_address != null ? try(split("/", var.ip_address)[1], "32") : null
65
tags = var.tags != null ? var.tags : try(data.netbox_cluster.main[0].tags, [])
76
}
87

98
resource "netbox_virtual_machine" "main" {
10-
name = local.fqdn
9+
name = var.zone != null ? local.fqdn : var.name
1110
role_id = data.netbox_device_role.main.id
1211
platform_id = data.netbox_platform.main.id
1312
site_id = var.site != null ? data.netbox_site.main[0].id : null

0 commit comments

Comments
 (0)