graphql-engine/server/test-manual/alloydb/alloydb.tf
Samir Talwar a0dc296ede Document and automate spinning up AlloyDB for testing.
We sometimes need to test against cloud databases. Here, we add a Terraform module to start a new AlloyDB cluster and instance, which we can then use for testing purposes.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7002
GitOrigin-RevId: 2d661b5cc6d60e47485ea68b781e13426ed4f097
2022-11-24 14:16:21 +00:00

35 lines
970 B
HCL

# The AlloyDB cluster, with a single instance.
# The initial user password must be provided.
variable "password" {
type = string
sensitive = true
}
resource "google_alloydb_cluster" "default" {
provider = google-beta
cluster_id = "${var.name}-testing-alloydb"
network = "projects/${data.google_project.project.number}/global/networks/${google_compute_network.default.name}"
location = local.region
initial_user {
user = var.name
password = var.password
}
}
resource "google_alloydb_instance" "primary" {
provider = google-beta
cluster = google_alloydb_cluster.default.name
instance_id = "${var.name}-testing-alloydb-instance"
instance_type = "PRIMARY"
depends_on = [
google_service_networking_connection.default
]
}
output "url" {
value = "postgresql://${var.name}:${var.password}@${google_compute_instance.bastion.network_interface.0.access_config.0.nat_ip}/postgres"
sensitive = true
}