This commit is contained in:
aissi
2025-12-04 11:01:15 +01:00
parent ed14be22c5
commit 0a7a83433f
3 changed files with 45 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
# Compte service terraform
resource "google_service_account" "terraform_sa" {
account_id = "terraform-sa"
display_name = "terraform compte service"
}
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" "custom_service_account" {
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" "cache" {
user = data.google_client_openid_userinfo.me.email
project = var.project_id
key = file("~/.ssh/id_ed25519.pub")
}

View File

@@ -0,0 +1,10 @@
output "service_account_email" {
description = "Service account email."
value = google_service_account.service_account.email
}
output "service_account_key" {
description = "Service account key."
sensitive = true
value = google_service_account_key.mykey.private_key
}

View File

@@ -1,2 +1,4 @@
# À vous de définir : variable "project_id" {
# - project_id (string) description = "ID du projet GCP dans lequel appliquer les règles IAM"
type = string
}