This commit is contained in:
Yanis DARIUS 2024-12-06 16:31:21 +01:00
parent 9262123ee7
commit 12fc45995b
8 changed files with 28 additions and 27 deletions

View File

@ -31,7 +31,7 @@ module "compute" {
source = "../../modules/compute" source = "../../modules/compute"
instance_type = "e2-micro" instance_type = "e2-micro"
zone ="europe-west4-a" zone ="europe-west9-c"
frontend_subnet_id = module.network.id_subnetwork["frontend"] frontend_subnet_id = module.network.id_subnetwork["frontend"]
backend_subnet_id = module.network.id_subnetwork["backend"] backend_subnet_id = module.network.id_subnetwork["backend"]
database_subnet_id = module.network.id_subnetwork["database"] database_subnet_id = module.network.id_subnetwork["database"]

View File

@ -1,48 +1,41 @@
#- project_name (string)
variable "project_name" { variable "project_name" {
description = "Nom du projet" description = "Nom du projet"
type = string type = string
default = "newtp-443913" default = "newtp-443913"
} }
#- project_id (string)
variable "project_id" { variable "project_id" {
description = "ID du projet" description = "projet id"
type = string type = string
default = "newtp-443913" default = "newtp-443913"
} }
# - region (string)
variable "region" { variable "region" {
description = "Région du projet" description = "Region"
type = string type = string
default = "europe-west4" default = "europe-west9"
} }
# - frontend_cidr (string)
variable "frontend_cidr" { variable "frontend_cidr" {
description = "cidr du frontend" description = "cidr du frontend"
type = string type = string
default = "10.0.1.0/24" default = "10.0.1.0/24"
} }
# - backend_cidr (string)
variable "backend_cidr" { variable "backend_cidr" {
description = "cidr du backend" description = "cidr du backend"
type = string type = string
default = "10.0.2.0/24" default = "10.0.2.0/24"
} }
# - database_cidr (string)
variable "database_cidr" { variable "database_cidr" {
description = "cidr du database" description = "cidr du db"
type = string type = string
default = "10.0.3.0/24" default = "10.0.3.0/24"
} }
# - ssh_source_ranges (string)
variable "ssh_source_ranges" { variable "ssh_source_ranges" {
description = "Accès à internet" description = "ssh"
type = string type = string
default = "0.0.0.0/0" default = "0.0.0.0/0"
} }

View File

@ -12,7 +12,7 @@ resource "google_compute_instance" "frontend" {
network_interface { network_interface {
subnetwork = var.frontend_subnet_id subnetwork = var.frontend_subnet_id
access_config {} # IP publique access_config {}
} }
tags = ["frontend", "ssh"] tags = ["frontend", "ssh"]
@ -36,7 +36,7 @@ resource "google_compute_instance" "backend" {
network_interface { network_interface {
subnetwork = var.backend_subnet_id subnetwork = var.backend_subnet_id
access_config {} # IP publique access_config {}
} }
tags = ["backend", "ssh"] tags = ["backend", "ssh"]
@ -60,7 +60,7 @@ resource "google_compute_instance" "database" {
network_interface { network_interface {
subnetwork = var.database_subnet_id subnetwork = var.database_subnet_id
access_config {} # IP publique access_config {}
} }
tags = ["database", "ssh"] tags = ["database", "ssh"]

View File

@ -1,5 +1,5 @@
output "instance_names" { output "instance_names" {
description = "Noms des instances" description = "Nom instance"
value = { value = {
frontend = google_compute_instance.frontend.name frontend = google_compute_instance.frontend.name
backend = google_compute_instance.backend.name backend = google_compute_instance.backend.name
@ -12,7 +12,7 @@ output "frontend_public_ip" {
} }
output "private_ip" { output "private_ip" {
description = "IPs internes de toutes les instances" description = "IP internes"
value = { value = {
frontend = google_compute_instance.frontend.network_interface[0].network_ip frontend = google_compute_instance.frontend.network_interface[0].network_ip
backend = google_compute_instance.backend.network_interface[0].network_ip backend = google_compute_instance.backend.network_interface[0].network_ip

View File

@ -7,7 +7,7 @@ variable "instance_type" {
variable "zone" { variable "zone" {
description = "zone des instances" description = "zone des instances"
type = string type = string
default = "europe-west4" default = "europe-west9"
} }
variable "frontend_subnet_id" { variable "frontend_subnet_id" {

View File

@ -3,3 +3,11 @@ variable "project_id" {
description = "ID du projet GCP" description = "ID du projet GCP"
type = string type = string
} }

View File

@ -9,3 +9,4 @@ output "id_subnetwork" {
database = google_compute_subnetwork.database_subnet.id database = google_compute_subnetwork.database_subnet.id
} }
} }

View File

@ -1,29 +1,28 @@
#- project_name (string)
variable "project_name" { variable "project_name" {
description = "Nom du projet" description = "Nom du projet"
type = string type = string
} }
# - region (string)
variable "region" { variable "region" {
description = "Région du projet" description = "Région du projet"
type = string type = string
} }
# - frontend_cidr (string)
variable "frontend_cidr" { variable "frontend_cidr" {
description = "cidr du frontend" description = "cidr du frontend"
type = string type = string
} }
# - backend_cidr (string)
variable "backend_cidr" { variable "backend_cidr" {
description = "cidr du backend" description = "cidr du backend"
type = string type = string
} }
# - database_cidr (string)
variable "database_cidr" { variable "database_cidr" {
description = "cidr du database" description = "cidr du database"
type = string type = string
} }
# - ssh_source_ranges (string)
variable "ssh_source_ranges" { variable "ssh_source_ranges" {
description = "Accès à internet" description = "Accès à internet"
type = string type = string