Skip to content

Commit

Permalink
Merge pull request #528 from lsst/u/stvoutsin/uws-cloudsql
Browse files Browse the repository at this point in the history
Create TAP cloudsql database on dev
  • Loading branch information
stvoutsin authored Jun 10, 2024
2 parents cb44ead + b9f4149 commit 1230dab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion environment/deployments/science-platform/cloudsql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ resource "random_password" "ssotap" {
special = false
}

resource "random_password" "obstap" {
length = 24
number = true
upper = true
special = false
}

data "google_compute_network" "network" {
name = var.network
project = var.project_id
Expand Down Expand Up @@ -116,6 +123,11 @@ module "db_science_platform" {
name = "ssotap"
charset = "UTF8"
collation = "en_US.UTF8"
},
{
name = "obstap"
charset = "UTF8"
collation = "en_US.UTF8"
}
]

Expand All @@ -139,6 +151,10 @@ module "db_science_platform" {
{
name = "ssotap"
password = random_password.ssotap.result
},
{
name = "obstap"
password = random_password.obstap.result
}
]

Expand Down Expand Up @@ -187,7 +203,7 @@ module "service_accounts" {
project_id = var.project_id
display_name = "PostgreSQL client"
description = "Terraform-managed service account for PostgreSQL access"
names = ["gafaelfawr", "nublado", "times-square", "vo-cutouts", "ssotap"]
names = ["gafaelfawr", "nublado", "times-square", "vo-cutouts", "ssotap", "obstap"]
project_roles = ["${var.project_id}=>roles/cloudsql.client"]
}

Expand Down Expand Up @@ -243,6 +259,12 @@ resource "google_service_account_iam_member" "ssotap_sa_wi" {
member = "serviceAccount:${var.project_id}.svc.id.goog[ssotap/ssotap]"
}

resource "google_service_account_iam_member" "obstap_sa_wi" {
service_account_id = module.service_accounts.service_accounts_map["obstap"].name
role = "roles/iam.workloadIdentityUser"
member = "serviceAccount:${var.project_id}.svc.id.goog[obstap/obstap]"
}

# The vo-cutouts service account must be granted the ability to generate
# tokens for itself so that it can generate signed GCS URLs starting from
# the GKE service account token without requiring an exported secret key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ db_maintenance_window_update_track = "canary"
backups_enabled = true

# Increase this number to force Terraform to update the dev environment.
# Serial: 12
# Serial: 13

0 comments on commit 1230dab

Please sign in to comment.