Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cluster and zone from Redis and PostgreSQL #69

Merged
merged 4 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions google/redis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@ module "netbox-vm" {

project = var.project

name = coalesce(var.hostname, var.name)
zone = var.zone
name = var.name
tags = [var.workspace]

role = "Redis"
platform = "Google Cloud"
site = var.site
cluster = var.cluster
site = "Google Cloud ${google_redis_instance.main.region}"

interface = "internal"
ip_address = google_redis_instance.main.host
Expand Down
25 changes: 5 additions & 20 deletions google/redis/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
variable "workspace" {
type = string
}

variable "project" {
type = string
}
Expand All @@ -8,27 +12,8 @@ variable "region" {
}

variable "name" {
type = string
}

variable "hostname" {
type = string
default = null
}

variable "zone" {
type = any
default = null
}

variable "site" {
type = any
default = null
}

variable "cluster" {
type = any
default = null
default = "redis"
}

variable "network" {
Expand Down
7 changes: 3 additions & 4 deletions google/sql/postgresql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,12 @@ module "netbox-vm" {

project = var.project

name = coalesce(var.hostname, var.name)
zone = var.zone
name = var.name
tags = [var.workspace]

role = "PostgreSQL"
platform = "Google Cloud"
site = coalesce(var.site, "Google Cloud ${google_sql_database_instance.main.region}")
cluster = var.cluster
site = "Google Cloud ${google_sql_database_instance.main.region}"

interface = "internal"
ip_address = google_sql_database_instance.main.private_ip_address
Expand Down
24 changes: 4 additions & 20 deletions google/sql/postgresql/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
variable "workspace" {
type = string
}

variable "project" {
type = string
}
Expand All @@ -12,26 +16,6 @@ variable "name" {
default = "postgres"
}

variable "hostname" {
type = string
default = null
}

variable "zone" {
type = any
default = null
}

variable "site" {
type = any
default = null
}

variable "cluster" {
type = any
default = null
}

variable "database_version" {
type = string
default = "POSTGRES_17"
Expand Down
5 changes: 2 additions & 3 deletions netbox/vm/main.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
locals {
domain = try(trimsuffix(var.zone.dns_name, "."), "local")
fqdn = "${var.name}.${local.domain}"
fqdn = var.zone != null ? "${var.name}.${trimsuffix(var.zone.dns_name, ".")}" : null
ip_address = var.ip_address != null ? split("/", var.ip_address)[0] : null
ip_prefix = var.ip_address != null ? try(split("/", var.ip_address)[1], "32") : null
tags = var.tags != null ? var.tags : try(data.netbox_cluster.main[0].tags, [])
}

resource "netbox_virtual_machine" "main" {
name = local.fqdn
name = var.zone != null ? local.fqdn : var.name
role_id = data.netbox_device_role.main.id
platform_id = data.netbox_platform.main.id
site_id = var.site != null ? data.netbox_site.main[0].id : null
Expand Down
Loading