#VPC resource "google_compute_network" "tp07" { name = "tp07" auto_create_subnetworks = false } resource "google_compute_subnetwork" "tp07-frontend" { name = "tp07-frontend" network = google_compute_network.vpc.id ip_cidr_range = var.frontend_cidr region = "europe-west4" } resource "google_compute_subnetwork" "tp07-backend" { name = "tp07-backend" network = google_compute_network.vpc.id ip_cidr_range = var.backend_cidr region = "europe-west4" } resource "google_compute_subnetwork" "tp07-database" { name = "tp07-database" network = google_compute_network.vpc.id ip_cidr_range = var.database_cidr region = "europe-west4" } resource "google_compute_firewall" "allow_http_https" { name = "allow-http-https" network = google_compute_network.vpc.id allow { protocol = "tcp" ports = ["80", "443"] } source_ranges = ["0.0.0.0/0"] target_tags = ["frontend"] } resource "google_compute_firewall" "allow_ssh" { name = "allow-ssh" network = google_compute_network.vpc.id allow { protocol = "tcp" ports = ["22"] } source_ranges = ["0.0.0.0/0"] target_tags = ["ssh"] } resource "google_compute_firewall" "allow_front-back" { name = "allow-front-back" network = google_compute_network.vpc.id allow { protocol = "tcp" ports = ["8000"] } source_tags = ["frontend"] target_tags = ["backend"] } resource "google_compute_firewall" "allow_back-database" { name = "allow-front-back" network = google_compute_network.vpc.id allow { protocol = "tcp" ports = ["3306"] } source_tags = ["backend"] target_tags = ["database"] }