bcp de chose
This commit is contained in:
72
modules/compute/main.tf
Normal file
72
modules/compute/main.tf
Normal file
@@ -0,0 +1,72 @@
|
||||
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_subnetwork.subnet.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_subnetwork.subnet.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_subnetwork.subnet.id
|
||||
access_config {} # IP publique
|
||||
}
|
||||
|
||||
tags = ["database", "ssh"]
|
||||
|
||||
metadata = {
|
||||
enable-oslogin = "TRUE"
|
||||
}
|
||||
}
|
||||
|
4
modules/compute/outputs.tf
Normal file
4
modules/compute/outputs.tf
Normal file
@@ -0,0 +1,4 @@
|
||||
# Output
|
||||
output "instance_ip" {
|
||||
value = google_compute_instance.main.network_interface[0].access_config[0].nat_ip
|
||||
}
|
31
modules/compute/variables.tf
Normal file
31
modules/compute/variables.tf
Normal file
@@ -0,0 +1,31 @@
|
||||
variable "instance_type" {
|
||||
description = "type d'instance"
|
||||
type = string
|
||||
default = "e2-micro"
|
||||
}
|
||||
|
||||
variable "zone" {
|
||||
description = "zone"
|
||||
type = string
|
||||
default = "europe-west4-a"
|
||||
}
|
||||
|
||||
variable "frontend_subnet_id" {
|
||||
description = "front sub id"
|
||||
type = string
|
||||
default = "10.0.1.0/24"
|
||||
}
|
||||
|
||||
variable "backend_subnet_id" {
|
||||
description = "back sub id"
|
||||
type = string
|
||||
default = "10.0.2.0/24"
|
||||
}
|
||||
|
||||
variable "database_subnet_id" {
|
||||
description = "data sub id"
|
||||
type = string
|
||||
default = "10.0.3.0/24"
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user