This commit is contained in:
Florian GENIQUE 2024-12-06 15:51:04 +01:00
parent a19d6855b2
commit d376bf9e98
4 changed files with 33 additions and 7 deletions

View File

@ -41,9 +41,9 @@ module "compute" {
zone = var.zone zone = var.zone
instance_type = var.instance_type instance_type = var.instance_type
frontend_subnet_id = module.network.id_subnetwork["frontend"] sub1 = module.network.subnet["frontend"]
backend_subnet_id = module.network.id_subnetwork["backend"] sub2 = module.network.subnet["backend"]
database_subnet_id = module.network.id_subnetwork["database"] sub3 = module.network.subnet["database"]

View File

@ -10,7 +10,7 @@ resource "google_compute_instance" "vm-front" {
} }
} }
network_interface { network_interface {
subnetwork = google_compute_network.frontend_subnet_id subnetwork = var.sub1
access_config {} # IP publique access_config {} # IP publique
} }
@ -35,7 +35,7 @@ resource "google_compute_instance" "vm-back" {
} }
network_interface { network_interface {
subnetwork = google_compute_network.backend_subnet_id subnetwork = var.sub2
access_config {} # IP publique access_config {} # IP publique
} }
@ -59,7 +59,7 @@ resource "google_compute_instance" "vm-database" {
} }
network_interface { network_interface {
subnetwork = google_compute_network.database_subnet_id subnetwork = var.sub3
access_config {} # IP publique access_config {} # IP publique
} }

View File

@ -28,4 +28,20 @@ variable "database_cidr" {
default = "10.0.3.0/24" default = "10.0.3.0/24"
} }
variable "sub1" {
description = "subnet front"
type = string
}
variable "sub2" {
description = "subnet back"
type = string
}
variable "sub3" {
description = "subnet database"
type = string
}

View File

@ -1 +1,11 @@
# Output d'un module output "vpc"{
value = google_compute_network.vpc.id
}
output "subnet" {
value = {
frontend = google_compute_subnetwork.subnet_front.id,
backend = google_compute_subnetwork.subnet_back.id,
database = google_compute_subnetwork.subnet_db.id
}
}