File tree Expand file tree Collapse file tree 5 files changed +17
-51
lines changed Expand file tree Collapse file tree 5 files changed +17
-51
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,12 @@ module "netbox-vm" {
3737
3838 project = var. project
3939
40- name = coalesce ( var. hostname , var . name )
41- zone = var. zone
40+ name = var. name
41+ tags = [ var . workspace ]
4242
4343 role = " Redis"
4444 platform = " Google Cloud"
45- site = var. site
46- cluster = var. cluster
45+ site = " Google Cloud ${ google_redis_instance . main . region } "
4746
4847 interface = " internal"
4948 ip_address = google_redis_instance. main . host
Original file line number Diff line number Diff line change 1+ variable "workspace" {
2+ type = string
3+ }
4+
15variable "project" {
26 type = string
37}
@@ -8,27 +12,8 @@ variable "region" {
812}
913
1014variable "name" {
11- type = string
12- }
13-
14- variable "hostname" {
1515 type = string
16- default = null
17- }
18-
19- variable "zone" {
20- type = any
21- default = null
22- }
23-
24- variable "site" {
25- type = any
26- default = null
27- }
28-
29- variable "cluster" {
30- type = any
31- default = null
16+ default = " redis"
3217}
3318
3419variable "network" {
Original file line number Diff line number Diff line change @@ -85,13 +85,12 @@ module "netbox-vm" {
8585
8686 project = var. project
8787
88- name = coalesce ( var. hostname , var . name )
89- zone = var. zone
88+ name = var. name
89+ tags = [ var . workspace ]
9090
9191 role = " PostgreSQL"
9292 platform = " Google Cloud"
93- site = coalesce (var. site , " Google Cloud ${ google_sql_database_instance . main . region } " )
94- cluster = var. cluster
93+ site = " Google Cloud ${ google_sql_database_instance . main . region } "
9594
9695 interface = " internal"
9796 ip_address = google_sql_database_instance. main . private_ip_address
Original file line number Diff line number Diff line change 1+ variable "workspace" {
2+ type = string
3+ }
4+
15variable "project" {
26 type = string
37}
@@ -12,26 +16,6 @@ variable "name" {
1216 default = " postgres"
1317}
1418
15- variable "hostname" {
16- type = string
17- default = null
18- }
19-
20- variable "zone" {
21- type = any
22- default = null
23- }
24-
25- variable "site" {
26- type = any
27- default = null
28- }
29-
30- variable "cluster" {
31- type = any
32- default = null
33- }
34-
3519variable "database_version" {
3620 type = string
3721 default = " POSTGRES_17"
Original file line number Diff line number Diff line change 11locals {
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
98resource "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
You can’t perform that action at this time.
0 commit comments