terraform { required_providers { google = { source = "hashicorp/google" version = "4.74.0" } } } provider "google" { project = "multichannel-chat-widget" region = "asia-east1" } resource "google_compute_network" "vpc_network" { name = "multichannel-chat-network" auto_create_subnetworks = false mtu = 1460 } resource "google_compute_subnetwork" "default" { name = "multichannel-chat-subnet" ip_cidr_range = "10.0.1.0/24" region = "asia-east1" network = google_compute_network.vpc_network.id } # Create a single Compute Engine instance resource "google_compute_instance" "default" { name = "multichannel-chat-vm" machine_type = "f1-micro" zone = "asia-east1-a" tags = ["ssh"] boot_disk { initialize_params { image = "debian-cloud/debian-11" } } # Install requirements metadata_startup_script = "sudo apt-get update; sudo apt-get install -yq build-essential python3-pip rsync; pip install -r requirements.txt" network_interface { subnetwork = google_compute_subnetwork.default.id access_config { # Include this section to give the VM an external IP address } } } resource "google_compute_firewall" "ssh" { name = "allow-ssh" allow { ports = ["22"] protocol = "tcp" } direction = "INGRESS" network = google_compute_network.vpc_network.id priority = 1000 source_ranges = ["0.0.0.0/0"] target_tags = ["ssh"] }