Skip to content

Commit 3be3023

Browse files
authored
Merge pull request #31 from puppetlabs/custom_domains
Provide capability to use custom dns
2 parents 651c95f + e5780f9 commit 3be3023

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ module "instances" {
138138
labels = var.labels
139139
metadata = var.metadata
140140
project = var.project
141+
domain_name = var.domain_name
141142
server_count = data.hiera5.server_count.value
142143
database_count = data.hiera5.database_count.value
143144
compiler_type = data.hiera5.compiler_type.value

modules/instances/main.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resource "google_compute_instance" "server" {
1616
# metadata so it is a property of the instance, making it easy to use later in
1717
# Bolt
1818
metadata = merge({
19-
"internalDNS" = "pe-server-${var.id}-${count.index}.${element(var.zones, count.index)}.c.${var.project}.internal"
19+
"internalDNS" = var.domain_name == null ? "pe-server-${var.id}-${count.index}.${element(var.zones, count.index)}.c.${var.project}.internal" : "pe-server-${var.id}-${count.index}.${var.domain_name}"
2020
}, local.metadata)
2121

2222
labels = var.labels
@@ -57,7 +57,7 @@ resource "google_compute_instance" "psql" {
5757
zone = element(var.zones, count.index)
5858

5959
metadata = merge({
60-
"internalDNS" = "pe-psql-${var.id}-${count.index}.${element(var.zones, count.index)}.c.${var.project}.internal"
60+
"internalDNS" = var.domain_name == null ? "pe-psql-${var.id}-${count.index}.${element(var.zones, count.index)}.c.${var.project}.internal" : "pe-psql-${var.id}-${count.index}.${var.domain_name}"
6161
}, local.metadata)
6262

6363
labels = var.labels
@@ -92,7 +92,7 @@ resource "google_compute_instance" "compiler" {
9292
zone = element(var.zones, count.index)
9393

9494
metadata = merge({
95-
"internalDNS" = "pe-compiler-${var.id}-${count.index}.${element(var.zones, count.index)}.c.${var.project}.internal"
95+
"internalDNS" = var.domain_name == null ? "pe-compiler-${var.id}-${count.index}.${element(var.zones, count.index)}.c.${var.project}.internal" : "pe-compiler-${var.id}-${count.index}.${var.domain_name}"
9696
}, local.metadata)
9797

9898
labels = var.labels
@@ -126,7 +126,7 @@ resource "google_compute_instance" "node" {
126126
zone = element(var.zones, count.index)
127127

128128
metadata = merge({
129-
"internalDNS" = "pe-compiler-${var.id}-${count.index}.${element(var.zones, count.index)}.c.${var.project}.internal"
129+
"internalDNS" = var.domain_name == null ? "pe-node-${var.id}-${count.index}.${element(var.zones, count.index)}.c.${var.project}.internal" : "pe-node-${var.id}-${count.index}.${var.domain_name}"
130130
}, local.metadata)
131131

132132
labels = var.labels

modules/instances/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,9 @@ variable "primary_disk" {
8888
variable "database_disk" {
8989
description = "Instance disk size of PuppetDB database and replica"
9090
type = string
91+
}
92+
variable "domain_name" {
93+
description = "Custom domain to use for internalDNS"
94+
type = string
95+
default = null
9196
}

modules/loadbalancer/outputs.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Output data that will be used by other submodules to build other parts of the
22
# stack to support defined architecture
33
output "lb_dns_name" {
4-
value = var.has_lb ? try(google_compute_forwarding_rule.pe_compiler_lb[0].service_name, ""): tolist(var.instances)[0].metadata["internalDNS"]
4+
value = var.has_lb ? try(google_compute_forwarding_rule.pe_compiler_lb[0].service_name, google_compute_forwarding_rule.pe_compiler_lb[0].ip_address): tolist(var.instances)[0].metadata["internalDNS"]
55
description = "The DNS name of either the load balancer fronting the compiler pool or the primary master, depending on architecture"
6-
}
6+
}

variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,9 @@ variable "disable_lb" {
100100
description = "Disable load balancer creation for all architectures if you desire manually provisioning your own"
101101
type = bool
102102
default = false
103+
}
104+
variable "domain_name" {
105+
description = "Custom domain to use for internalDNS"
106+
type = string
107+
default = null
103108
}

0 commit comments

Comments
 (0)