Skip to content

Commit a6ed667

Browse files
authored
Merge pull request #69 from remerge/remove-cluster-zone
Remove cluster and zone from Redis and PostgreSQL
2 parents ca4d5c6 + 0ed4335 commit a6ed667

File tree

5 files changed

+17
-51
lines changed

5 files changed

+17
-51
lines changed

google/redis/main.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff 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

google/redis/variables.tf

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
variable "workspace" {
2+
type = string
3+
}
4+
15
variable "project" {
26
type = string
37
}
@@ -8,27 +12,8 @@ variable "region" {
812
}
913

1014
variable "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

3419
variable "network" {

google/sql/postgresql/main.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff 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

google/sql/postgresql/variables.tf

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
variable "workspace" {
2+
type = string
3+
}
4+
15
variable "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-
3519
variable "database_version" {
3620
type = string
3721
default = "POSTGRES_17"

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)