Skip to content

Commit

Permalink
Set up an internal domain name for DP02 database
Browse files Browse the repository at this point in the history
Add a private DNS name for the DP02 Cloud SQL instance to the VPC, so we don't have to hard-code IP addresses in configuration.
  • Loading branch information
dhirving committed Jan 17, 2025
1 parent 3ea6a08 commit b5f6a51
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions environment/deployments/science-platform/cloudsql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ moved {
to = module.db_butler_registry_dp02[0]
}

resource "google_dns_managed_zone" "sql_private_zone" {
name = "sql-private-zone"
dns_name = "rsp-sql-${var.environment}.internal."
description = "DNS Zone containing domain names used to access internal databases."

visibility = "private"

private_visibility_config {
networks {
network_url = data.google_compute_network.network.id
}
}
}

resource "google_dns_record_set" "dp02" {
count = var.butler_registry_dp02_enable ? 1 : 0

managed_zone = google_dns_managed_zone.sql_private_zone.name
name = "dp02.${google_dns_managed_zone.sql_private_zone.dns_name}"
type = "A"
rrdatas = [module.db_butler_registry_dp02.private_ip_address]
ttl = 1800
}


resource "random_password" "gafaelfawr" {
length = 24
numeric = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ science_platform_db_maintenance_window_update_track = "canary"
science_platform_backups_enabled = true

# Increase this number to force Terraform to update the dev environment.
# Serial: 20
# Serial: 21
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ science_platform_db_maintenance_window_hour = 22
science_platform_backups_enabled = true

# Increase this number to force Terraform to update the int environment.
# Serial: 8
# Serial: 9

0 comments on commit b5f6a51

Please sign in to comment.