# À vous de créer :

# 1. Instance frontend :
#    - Image : debian-11
#    - Disque : 10GB
#    - IP publique
#    - Tags : frontend, ssh
#    - OS Login enabled

# 2. Instance backend :
#    - Image : debian-11
#    - Disque : 10GB
#    - Pas d'IP publique (interne seulement)
#    - Tags : backend, ssh
#    - OS Login enabled

# 3. Instance database :
#    - Image : debian-11
#    - Disque : 20GB
#    - Pas d'IP publique
#    - Tags : database, ssh
#    - OS Login enabled

resource "google_compute_instance" "frontend" {
name = "frontend"
machine_type = var.instance_type
zone = var.zone


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


network_interface {
subnetwork = var.frontend_subnet_id


access_config {}
}


metadata = {
enable-oslogin = "TRUE"
}


tags = ["frontend", "ssh"]
}


resource "google_compute_instance" "backend" {
name = "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
}


metadata = {
enable-oslogin = "TRUE"
}


tags = ["backend", "ssh"]
}


resource "google_compute_instance" "database" {
name = "database"
machine_type = var.instance_type
zone = var.zone


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


network_interface {
subnetwork = var.database_subnet_id
}


metadata = {
enable-oslogin = "TRUE"
}


tags = ["database", "ssh"]
}