on espere ca va marcher

This commit is contained in:
2025-12-03 15:22:51 +01:00
parent e67b5bf03c
commit 370e3e3aa2
12 changed files with 419 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
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 {} # IP publique
}
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
# Pas d'IP publique
}
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
# Pas d'IP publique
}
metadata = {
enable-oslogin = "TRUE"
}
tags = ["database", "ssh"]
}

View File

@@ -0,0 +1,23 @@
output "frontend_internal_ip" {
value = google_compute_instance.frontend.network_interface[0].network_ip
}
output "backend_internal_ip" {
value = google_compute_instance.backend.network_interface[0].network_ip
}
output "database_internal_ip" {
value = google_compute_instance.database.network_interface[0].network_ip
}
output "frontend_public_ip" {
value = google_compute_instance.frontend.network_interface[0].access_config[0].nat_ip
}
output "instance_names" {
value = [
google_compute_instance.frontend.name,
google_compute_instance.backend.name,
google_compute_instance.database.name
]
}

View File

@@ -0,0 +1,26 @@
variable "instance_type" {
description = "Type de machine pour les instances"
type = string
default = "e2-medium"
}
variable "zone" {
description = "Zone où seront déployées les instances"
type = string
default = "europe-west1-b"
}
variable "frontend_subnet_id" {
description = "ID du subnet pour le frontend"
type = string
}
variable "backend_subnet_id" {
description = "ID du subnet pour le backend"
type = string
}
variable "database_subnet_id" {
description = "ID du subnet pour la base de données"
type = string
}