forked from pierront/but3-iac
Suite
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# Commentaire
|
||||
terraform {
|
||||
required_providers {
|
||||
google = {
|
||||
@@ -22,3 +23,18 @@ module "network" {
|
||||
ssh_source_ranges = var.ssh_source_ranges
|
||||
|
||||
}
|
||||
|
||||
|
||||
module "compute" {
|
||||
source = "../../modules/compute"
|
||||
instance_type = var.instance_type
|
||||
zone = var.zone
|
||||
frontend_subnet_id = module.network.subnet_ids.frontend
|
||||
backend_subnet_id = module.network.subnets.backend
|
||||
database_subnet_id = module.network.subnets.database
|
||||
}
|
||||
|
||||
module "iam" {
|
||||
source = "../../modules/iam"
|
||||
project_id = var.project_id
|
||||
}
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
output "ip_internes" {
|
||||
value = {
|
||||
frontend = google_compute_instance.vm_frontend.network_interface[0].network_ip
|
||||
backend = google_compute_instance.vm_backend.network_interface[0].network_ip
|
||||
database = google_compute_instance.vm_database.network_interface[0].network_ip
|
||||
}
|
||||
value = module.compute.ip_internes
|
||||
}
|
||||
|
||||
output "ip_public_frontend" {
|
||||
value = google_compute_instance.vm_frontend.network_interface[0].access_config[0].nat_ip
|
||||
value = module.compute.vm_frontend.network_interface[0].access_config[0].nat_ip
|
||||
}
|
||||
|
||||
output "nom_instances" {
|
||||
value = {
|
||||
frontend = google_compute_instance.vm_frontend.name
|
||||
frontend = module.compute.nom_instances.vm_frontend
|
||||
backend = google_compute_instance.vm_backend.name
|
||||
database = google_compute_instance.vm_database.name
|
||||
}
|
||||
|
||||
@@ -44,3 +44,26 @@ variable "project_id"{
|
||||
|
||||
|
||||
}
|
||||
|
||||
variable "instance_type" {
|
||||
description = "Type de machine à utiliser pour les instances"
|
||||
type = string
|
||||
default = "e2-small"
|
||||
|
||||
}
|
||||
|
||||
variable "zone" {
|
||||
description = "Zone où déployer les instances"
|
||||
type = string
|
||||
default = "europe-west9-b"
|
||||
}
|
||||
|
||||
|
||||
variable "project_id" {
|
||||
description = "Le projet ID"
|
||||
type = string
|
||||
default = "instance-20251203-132021"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
resource "google_service_account" "myaccount" {
|
||||
account_id = "terraform"
|
||||
display_name = "terraform"
|
||||
}
|
||||
|
||||
resource "google_service_account_key" "mykey" {
|
||||
service_account_id = google_service_account.myaccount.name
|
||||
public_key_type = "TYPE_X509_PEM_FILE"
|
||||
}
|
||||
|
||||
|
||||
resource "google_project_iam_binding" "project_iam" {
|
||||
project = var.project_id
|
||||
role = "roles/view"
|
||||
|
||||
members = [
|
||||
"serviceAccount:${google_service_account.myaccount.email}",
|
||||
]
|
||||
|
||||
|
||||
}
|
||||
|
||||
data "google_client_openid_userinfo" "me" {
|
||||
}
|
||||
|
||||
resource "google_os_login_ssh_public_key" "cache" {
|
||||
user = data.google_client_openid_userinfo.me.email
|
||||
key = file("~/.ssh/id_ed25519")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
variable "project_id" {
|
||||
description = "Le projet ID"
|
||||
type = string
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user