Skip to content

Commit c1c61a3

Browse files
authored
Merge pull request #25 from sparkfabrik/task/suffix_split
refs platform/1680: Split random suffix among postgres and cloud nat
2 parents b67c744 + 308f1f4 commit c1c61a3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

main.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ provider "kubernetes" {
4141

4242
locals {
4343
# Postgres DB Name
44-
gitlab_db_name = var.postgresql_db_random_suffix ? "${var.gitlab_db_name}-${random_id.suffix[0].hex}" : var.gitlab_db_name
44+
gitlab_db_name = var.postgresql_db_random_suffix ? "${var.gitlab_db_name}-${random_id.postgres_suffix[0].hex}" : var.gitlab_db_name
4545

4646
buckets = [
4747
"artifacts",
@@ -62,8 +62,8 @@ locals {
6262
subnet_name_service_cidr = "gitlab-cluster-service-cidr"
6363
}
6464

65-
resource "random_id" "suffix" {
66-
count = var.postgresql_db_random_suffix ? 2 : 1
65+
resource "random_id" "postgres_suffix" {
66+
count = var.postgresql_db_random_suffix ? 1 : 0
6767
byte_length = 4
6868
}
6969

@@ -131,13 +131,17 @@ resource "google_compute_address" "gitlab" {
131131
count = var.gitlab_address_name == "" ? 1 : 0
132132
}
133133

134+
resource "random_id" "cloudnat_suffix" {
135+
byte_length = 4
136+
}
137+
134138
module "cloud_nat" {
135139
source = "terraform-google-modules/cloud-nat/google"
136140
version = "~> 2.2.0"
137141
project_id = var.project_id
138142
region = var.region
139143
router = format("%s-router", var.project_id)
140-
name = "${var.project_id}-cloud-nat-${random_id.suffix[1].hex}"
144+
name = "${var.project_id}-cloud-nat-${random_id.cloudnat_suffix.hex}"
141145
network = google_compute_network.gitlab.self_link
142146
create_router = true
143147
min_ports_per_vm = "2048"

0 commit comments

Comments
 (0)