IAM
This commit is contained in:
73
terraform/modules/compute/main.tf
Normal file
73
terraform/modules/compute/main.tf
Normal 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 = var.sub1
|
||||
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 = var.sub2
|
||||
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 = var.sub3
|
||||
access_config {} # IP publique
|
||||
}
|
||||
|
||||
tags = ["database", "ssh"]
|
||||
|
||||
metadata = {
|
||||
enable-oslogin = "TRUE"
|
||||
}
|
||||
}
|
||||
|
||||
|
18
terraform/modules/compute/outputs.tf
Normal file
18
terraform/modules/compute/outputs.tf
Normal file
@@ -0,0 +1,18 @@
|
||||
output "Intern"{
|
||||
value = {
|
||||
ip_front = google_compute_instance.vm-front.network_interface[0].network_ip,
|
||||
ip_back = google_compute_instance.vm-back.network_interface[0].network_ip,
|
||||
ip_db = google_compute_instance.vm-database.network_interface[0].network_ip
|
||||
}
|
||||
}
|
||||
|
||||
output "frontend_public_ip" {
|
||||
value = google_compute_instance.vm-front.network_interface[0].access_config[0].nat_ip
|
||||
}
|
||||
output "name"{
|
||||
value = {
|
||||
name_frontend = google_compute_instance.vm-front.name
|
||||
name_backend = google_compute_instance.vm-back.name
|
||||
name_database = google_compute_instance.vm-database.name
|
||||
}
|
||||
}
|
25
terraform/modules/compute/variables.tf
Normal file
25
terraform/modules/compute/variables.tf
Normal file
@@ -0,0 +1,25 @@
|
||||
variable "instance_type" {
|
||||
description = "type d'instance"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "zone" {
|
||||
description = "zone"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "sub1"{
|
||||
description = "subnet1 frontend"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "sub2"{
|
||||
description = "subnet2 backend"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "sub3"{
|
||||
description = "subnet3 database"
|
||||
type = string
|
||||
}
|
||||
|
Reference in New Issue
Block a user