2025-12-03 16:12:20 +00:00
|
|
|
resource "google_service_account" "terraform_sa" {
|
2025-12-04 10:13:59 +01:00
|
|
|
account_id = "terraform"
|
|
|
|
|
display_name = "Service Account pour Terraform Automation"
|
2025-12-03 16:12:20 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-04 10:13:59 +01:00
|
|
|
resource "google_service_account_key" "terraform_sa_key" {
|
|
|
|
|
service_account_id = google_service_account.terraform_sa.name
|
|
|
|
|
public_key_type = "TYPE_X509_PEM_FILE"
|
2025-12-03 16:12:20 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-04 10:13:59 +01:00
|
|
|
resource "google_project_iam_binding" "terraform_viewer" {
|
|
|
|
|
project = var.project_id
|
|
|
|
|
role = "roles/viewer"
|
2025-12-03 16:12:20 +00:00
|
|
|
|
2025-12-04 10:13:59 +01:00
|
|
|
members = [
|
|
|
|
|
"serviceAccount:${google_service_account.terraform_sa.email}",
|
|
|
|
|
]
|
2025-12-03 16:12:20 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-04 10:13:59 +01:00
|
|
|
data "google_client_openid_userinfo" "me" {}
|
|
|
|
|
|
|
|
|
|
resource "google_os_login_ssh_public_key" "my_ssh_key" {
|
|
|
|
|
user = data.google_client_openid_userinfo.me.email
|
|
|
|
|
key = file("~/.ssh/id_ed25519.pub")
|
2025-12-03 16:12:20 +00:00
|
|
|
}
|