1
0
forked from pierront/but3-iac

iam debut

This commit is contained in:
2025-12-04 10:15:25 +01:00
parent 40d03d2b5a
commit 5527d753c0
4 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
resource "google_service_account" "terraform_sa" {
account_id = "terraform"
display_name = "Service Account Terraform"
}
resource "google_service_account_key" "terraform_sa_key" {
service_account_id = google_service_account.terraform_sa.name
public_key_type = "TYPE_X509_PEM_FILE"
}
resource "google_project_iam_binding" "terraform_sa_viewer" {
project = var.project_id
role = "roles/viewer"
members = [
"serviceAccount:${google_service_account.terraform_sa.email}"
]
}
data "google_client_openid_userinfo" "me" {}
resource "google_os_login_ssh_public_key" "me_ssh_key" {
user = data.google_client_openid_userinfo.me.email
key = file(var.ssh_public_key_path)
}

View File

@@ -0,0 +1,8 @@
output "service_account_email" {
value = google_service_account.terraform_sa.email
}
output "service_account_key" {
value = google_service_account_key.terraform_sa_key.private_key
sensitive = true
}

View File

@@ -0,0 +1,8 @@
variable "project_id" {
type = string
}
variable "ssh_public_key_path" {
type = string
description = "Chemin vers la clé publique SSH"
}