forked from pierront/but3-iac
encore xje sais plus
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
|
||||
# Instance front-end
|
||||
|
||||
resource "google_compute_instance" "frontend_vm" {
|
||||
name = "frontend-vm"
|
||||
machine_type = "e2-medium"
|
||||
zone = "europe-west1-b"
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = "debian-cloud/debian-11"
|
||||
size = 10
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
access_config {} # IP publique
|
||||
subnetwork = google_compute_subnetwork.subnet_frontend.id
|
||||
}
|
||||
|
||||
tags = ["frontend", "ssh"]
|
||||
|
||||
metadata = {
|
||||
enable-oslogin = "TRUE"
|
||||
}
|
||||
}
|
||||
|
||||
# Instance back-end
|
||||
|
||||
resource "google_compute_instance" "backend_vm" {
|
||||
name = "backend-vm"
|
||||
machine_type = "e2-medium"
|
||||
zone = "europe-west1-b"
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = "debian-cloud/debian-11"
|
||||
size = 10
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
|
||||
subnetwork = google_compute_subnetwork.subnet_backend.id
|
||||
}
|
||||
|
||||
tags = ["backend", "ssh"]
|
||||
|
||||
metadata = {
|
||||
enable-oslogin = "TRUE"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Instance data-base
|
||||
|
||||
resource "google_compute_instance" "database_vm" {
|
||||
name = "database-vm"
|
||||
machine_type = "e2-medium"
|
||||
zone = "europe-west1-b"
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = "debian-cloud/debian-11"
|
||||
size = 20
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
|
||||
subnetwork = google_compute_subnetwork.subnet_database.id
|
||||
}
|
||||
|
||||
tags = ["database", "ssh"]
|
||||
|
||||
metadata = {
|
||||
enable-oslogin = "TRUE"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,21 +7,26 @@
|
||||
|
||||
|
||||
variable "instance_type" {
|
||||
description = "type de l'instance"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "zone" {
|
||||
description = "région"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "frontend_subnet_id" {
|
||||
type = number
|
||||
description = "front-end id"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "backend_subnet_id" {
|
||||
type = number
|
||||
description = "back-end id"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "database_subnet_id" {
|
||||
type = number
|
||||
description = "database id"
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ resource "google_compute_firewall" "allow-http" {
|
||||
}
|
||||
|
||||
# - SSH vers toutes les instances
|
||||
resource "google_compute_firewall" "vers-instances" {
|
||||
name = "instances"
|
||||
resource "google_compute_firewall" "to-instances" {
|
||||
name = "to-instances"
|
||||
network = google_compute_network.vpc.id
|
||||
|
||||
allow {
|
||||
|
||||
@@ -2,10 +2,10 @@ output "vpc_terraform_output" {
|
||||
value = google_compute_network.vpc.id
|
||||
}
|
||||
|
||||
output "list_id" {
|
||||
output "subnets" {
|
||||
value = {
|
||||
frontend = google_compute_network.vpc.id
|
||||
backend = google_compute_network.vpc.id
|
||||
database = google_compute_network.vpc.id
|
||||
frontend = google_compute_subnetwork.subnet_frontend.id
|
||||
backend = google_compute_subnetwork.subnet_backend.id
|
||||
database = google_compute_subnetwork.subnet_database.id
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user