diff --git a/environments/dev/main.tf b/environments/dev/main.tf index e75c4d5..a21a2e3 100644 --- a/environments/dev/main.tf +++ b/environments/dev/main.tf @@ -41,9 +41,9 @@ module "compute" { zone = var.zone instance_type = var.instance_type - frontend_subnet_id = module.network.id_subnetwork["frontend"] - backend_subnet_id = module.network.id_subnetwork["backend"] - database_subnet_id = module.network.id_subnetwork["database"] + sub1 = module.network.subnet["frontend"] + sub2 = module.network.subnet["backend"] + sub3 = module.network.subnet["database"] diff --git a/modules/compute/main.tf b/modules/compute/main.tf index 3b50357..2fc3959 100644 --- a/modules/compute/main.tf +++ b/modules/compute/main.tf @@ -10,7 +10,7 @@ resource "google_compute_instance" "vm-front" { } } network_interface { - subnetwork = google_compute_network.frontend_subnet_id + subnetwork = var.sub1 access_config {} # IP publique } @@ -35,7 +35,7 @@ resource "google_compute_instance" "vm-back" { } network_interface { - subnetwork = google_compute_network.backend_subnet_id + subnetwork = var.sub2 access_config {} # IP publique } @@ -59,7 +59,7 @@ resource "google_compute_instance" "vm-database" { } network_interface { - subnetwork = google_compute_network.database_subnet_id + subnetwork = var.sub3 access_config {} # IP publique } diff --git a/modules/compute/variables.tf b/modules/compute/variables.tf index e12b2b7..2258d02 100644 --- a/modules/compute/variables.tf +++ b/modules/compute/variables.tf @@ -28,4 +28,20 @@ variable "database_cidr" { 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 +} diff --git a/modules/network/outputs.tf b/modules/network/outputs.tf index e763f74..0457b70 100644 --- a/modules/network/outputs.tf +++ b/modules/network/outputs.tf @@ -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 + } +} \ No newline at end of file