Created
March 20, 2024 07:23
-
-
Save ealebed/b9942f227bba1148cabb769ae4129794 to your computer and use it in GitHub Desktop.
example reverse proxy VM for datastream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Proxy VM | |
resource "google_compute_instance" "reverse-proxy" { | |
project = var.project # app-ref project | |
name = "reverse-proxy" | |
machine_type = "e2-medium" | |
zone = "asia-southeast1-b" | |
boot_disk { | |
initialize_params { | |
image = "debian-cloud/debian-11" | |
} | |
} | |
network_interface { | |
network = data.google_compute_network.network.name # shared network name | |
subnetwork = data.google_compute_subnetwork.subnetwork.id # subnetwork name | |
} | |
metadata_startup_script = <<EOT | |
#!/bin/sh | |
apt-get update | |
curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.9.0/cloud-sql-proxy.linux.amd64 | |
chmod +x cloud-sql-proxy | |
./cloud-sql-proxy --private-ip ${google_sql_database_instance.instance.connection_name} --address 0.0.0.0 --port 5432 | |
EOT | |
service_account { | |
scopes = ["cloud-platform"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment