Files
but3-iac/terraform/modules/iam/main.tf

28 lines
730 B
Terraform
Raw Normal View History

2025-12-04 10:56:55 +01:00
resource "google_service_account" "service_account" {
account_id = "terraform"
display_name = "terraform"
2025-12-04 10:37:24 +01:00
}
2025-12-04 11:05:05 +01:00
resource "google_service_account_key" "key" {
2025-12-04 10:56:55 +01:00
service_account_id = google_service_account.service_account.name
public_key_type = "TYPE_X509_PEM_FILE"
}
2025-12-04 10:37:24 +01:00
2025-12-04 11:05:05 +01:00
resource "google_project_iam_binding" "sa_viewer" {
2025-12-04 10:56:55 +01:00
project = var.project_id
role = "roles/viewer"
2025-12-04 10:37:24 +01:00
2025-12-04 10:56:55 +01:00
members = [
"serviceAccount:${google_service_account.service_account.email}",
]
2025-12-04 10:37:24 +01:00
}
2025-12-04 11:05:05 +01:00
# Ajout sécurité : OS Login
data "google_client_openid_userinfo" "me" {}
2025-12-04 10:37:24 +01:00
2025-12-04 11:05:05 +01:00
resource "google_os_login_ssh_public_key" "ssh_key" {
user = data.google_client_openid_userinfo.me.email
2025-12-04 10:37:24 +01:00
project = var.project_id
2025-12-04 11:05:05 +01:00
key = file(var.ssh_public_key_path)
}