This commit is contained in:
SimonSayeBabu 2024-12-06 15:31:31 +01:00
parent ea72883bb8
commit 4b13756f44
4 changed files with 46 additions and 0 deletions

View File

@ -38,4 +38,11 @@ module "compute" {
frontend_subnet_id = module.network.id_subnetwork["frontend"] frontend_subnet_id = module.network.id_subnetwork["frontend"]
backend_subnet_id = module.network.id_subnetwork["backend"] backend_subnet_id = module.network.id_subnetwork["backend"]
database_subnet_id = module.network.id_subnetwork["database"] database_subnet_id = module.network.id_subnetwork["database"]
}
module "iam" {
source = "../../modules/iam"
# Variables d'en"trée
project_id = var.project_id
} }

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
}