resource "google_compute_instance" "instance_frontend" {
  name         = "instance-de-frontend"
  machine_type = var.instance_type
  zone         = var.zone

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-11"
      size  = 10
    }
  }

  network_interface {
    access_config {} # IP publique
    subnetwork = var.frontend_subnet_id
  }

  tags = ["frontend", "ssh"]

  metadata = {
    enable-oslogin = "TRUE"
  }
}

resource "google_compute_instance" "instance_backend" {
  name         = "instance-de-backend"
  machine_type = var.instance_type
  zone         = var.zone

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-11"
      size  = 10
    }
  }

  network_interface {
    subnetwork = var.backend_subnet_id
  }

  tags = ["backend", "ssh"]

  metadata = {
    enable-oslogin = "TRUE"
  }
}

resource "google_compute_instance" "instance_database" {
  name         = "instance-de-database"
  machine_type = var.instance_type
  zone         = var.zone

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-11"
      size  = 10
    }
  }

  network_interface {
    subnetwork = var.database_subnet_id
  }

  tags = ["database", "ssh"]

  metadata = {
    enable-oslogin = "TRUE"
  }
}