Created
October 13, 2022 12:40
-
-
Save marvinhoxha/9f5490a6a1290455115a60e21b321a12 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
resource "google_compute_instance" "default" { | |
project = var.project | |
name = "datastream-proxy" | |
machine_type = var.proxy_machine_type | |
zone = var.zone | |
boot_disk { | |
initialize_params { | |
image = "debian-cloud/debian-11" | |
} | |
} | |
network_interface { | |
network = data.google_compute_network.network.name | |
access_config { | |
// Ephemeral public IP | |
} | |
} | |
metadata_startup_script = <<EOT | |
#!/bin/sh | |
apt-get update | |
sudo apt-get install wget | |
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy | |
chmod +x cloud_sql_proxy | |
./cloud_sql_proxy -instances=${google_sql_database_instance.instance.connection_name}:pg-source=tcp:0.0.0.0: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