This commit is contained in:
Guillaume VALLAT 2024-12-06 16:05:50 +01:00
parent 6b00f916e7
commit 2c6a297c9b
16 changed files with 59 additions and 3 deletions

View File

View File

View File

@ -38,14 +38,13 @@ module "compute" {
zone = var.zone zone = var.zone
instance_type = var.instance_type instance_type = var.instance_type
} }
/*
module "iam" { module "iam" {
source = "../../modules/iam" source = "../../modules/iam"
# Variables d'entrée # Variables d'entrée
# Autres variables spécifiques au module # Autres variables spécifiques au module
project_id = var.project_id
} }
*/

View 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
}
}

View File

@ -0,0 +1,24 @@
resource "google_service_account" "service_account" {
account_id = "terraform"
display_name = "terraform"
}
resource "google_service_account_key" "service_account" {
service_account_id = google_service_account.service_account.name
public_key_type = "TYPE_X509_PEM_FILE"
}
resource "google_project_iam_binding" "service_account_roles" {
project = var.project_id
role = "roles/viewer"
members = ["serviceAccount:${google_service_account.service_account.email}"]
}
data "google_client_openid_userinfo" "me" {
}
resource "google_os_login_ssh_public_key" "add_my_key" {
project = var.project_id
user = data.google_client_openid_userinfo.me.email
key = file("~/.ssh/id_ed25519.pub")
}

View File

@ -0,0 +1,10 @@
output "service_account_email" {
description = "Email du compte de service"
value = google_service_account.service_account.email
}
output "service_account_key" {
description = "Clé du compte de service"
value = google_service_account_key.service_account.private_key
sensitive = true
}

View File

@ -0,0 +1,5 @@
# modules/iam/variables.tf
variable "project_id" {
description = "ID du projet GCP"
type = string
}