This commit is contained in:
2024-12-06 14:44:53 +01:00
commit 0f57df0692
12 changed files with 325 additions and 0 deletions

73
modules/compute/main.tf Normal file
View File

@@ -0,0 +1,73 @@
resource "google_compute_instance" "vm-front" {
name = "vm-front"
machine_type = var.instance_type
zone = var.zone
boot_disk {
initialize_params {
image = "debian-cloud/debian-11"
size = 10
}
}
network_interface {
subnetwork = google_compute_network.subnet_front.id
access_config {} # IP publique
}
tags = ["web", "ssh"]
metadata = {
enable-oslogin = "TRUE"
}
}
resource "google_compute_instance" "vm-back" {
name = "vm-back"
machine_type = var.instance_type
zone = var.zone
boot_disk {
initialize_params {
image = "debian-cloud/debian-11"
size = 10
}
}
network_interface {
subnetwork = google_compute_network.subnet_back.id
access_config {} # IP publique
}
tags = ["backend", "ssh"]
metadata = {
enable-oslogin = "TRUE"
}
}
resource "google_compute_instance" "vm-database" {
name = "vm"-database
machine_type = var.instance_type
zone = var.zone
boot_disk {
initialize_params {
image = "debian-cloud/debian-11"
size = 20
}
}
network_interface {
subnetwork = google_compute_network.subnet_db.id
access_config {} # IP publique
}
tags = ["database", "ssh"]
metadata = {
enable-oslogin = "TRUE"
}
}

View File

View File

@@ -0,0 +1,28 @@
variable "instance_type" {
description = "type d'instance"
type = string
default = "e2-micro"
}
variable "zone" {
description = "zone"
type = string
default = "europe-west4-a"
}
variable "frontend_cidr" {
description = "range_front"
type = string
}
variable "backend_cidr" {
description = "range_back"
type = string
}
variable "database_cidr" {
description = "range_database"
type = string
}