forked from pierront/but3-iac
ajout du network
This commit is contained in:
85
terraform/modules/compute/main.tf
Normal file
85
terraform/modules/compute/main.tf
Normal file
@@ -0,0 +1,85 @@
|
||||
// Récupération de l'image Debian 11
|
||||
data "google_compute_image" "debian_11" {
|
||||
family = "debian-11"
|
||||
project = "debian-cloud"
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "frontend" {
|
||||
name = "frontend-instance"
|
||||
machine_type = var.instance_type
|
||||
zone = var.zone
|
||||
|
||||
tags = ["frontend", "ssh"]
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = data.google_compute_image.debian_11.self_link
|
||||
size = 10 // 10GB
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
subnetwork = var.frontend_subnet_id
|
||||
|
||||
// IP publique
|
||||
access_config {}
|
||||
}
|
||||
|
||||
// OS Login activé
|
||||
metadata = {
|
||||
enable-oslogin = "TRUE"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
resource "google_compute_instance" "backend" {
|
||||
name = "backend-instance"
|
||||
machine_type = var.instance_type
|
||||
zone = var.zone
|
||||
|
||||
tags = ["backend", "ssh"]
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = data.google_compute_image.debian_11.self_link
|
||||
size = 10 // 10GB
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
subnetwork = var.backend_subnet_id
|
||||
// Pas d'access_config -> pas d'IP publique
|
||||
}
|
||||
|
||||
metadata = {
|
||||
enable-oslogin = "TRUE"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
resource "google_compute_instance" "database" {
|
||||
name = "database-instance"
|
||||
machine_type = var.instance_type
|
||||
zone = var.zone
|
||||
|
||||
tags = ["database", "ssh"]
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = data.google_compute_image.debian_11.self_link
|
||||
size = 20 // 20GB
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
subnetwork = var.database_subnet_id
|
||||
// Pas d'access_config -> pas d'IP publique
|
||||
}
|
||||
|
||||
metadata = {
|
||||
enable-oslogin = "TRUE"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user