graphql-engine/server/test-manual/alloydb/network.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

48 lines
1.4 KiB
HCL

# AlloyDB requires a dedicated virtual private network.
resource "google_compute_network" "default" {
name = "${var.name}-testing-alloydb-network"
}
resource "google_compute_global_address" "private_ip_alloc" {
name = "${var.name}-testing-alloydb-cluster"
address_type = "INTERNAL"
purpose = "VPC_PEERING"
prefix_length = 16
network = google_compute_network.default.id
}
resource "google_service_networking_connection" "default" {
network = google_compute_network.default.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}
# Allows instances with the tag "ssh" to expose port 22.
resource "google_compute_firewall" "ssh" {
name = "${var.name}-testing-alloydb-allow-ssh"
allow {
ports = ["22"]
protocol = "tcp"
}
direction = "INGRESS"
network = google_compute_network.default.id
priority = 1000
source_ranges = ["0.0.0.0/0"]
target_tags = ["ssh"]
}
# Allows instances with the tag "postgres" to expose port 5432.
resource "google_compute_firewall" "postgres" {
name = "${var.name}-testing-alloydb-allow-postgres"
allow {
ports = ["5432"]
protocol = "tcp"
}
direction = "INGRESS"
network = google_compute_network.default.id
priority = 1000
source_ranges = ["0.0.0.0/0"]
target_tags = ["postgres"]
}