forked from pierront/but3-iac
28 lines
730 B
HCL
28 lines
730 B
HCL
resource "google_service_account" "service_account" {
|
|
account_id = "terraform"
|
|
display_name = "terraform"
|
|
}
|
|
|
|
resource "google_service_account_key" "key" {
|
|
service_account_id = google_service_account.service_account.name
|
|
public_key_type = "TYPE_X509_PEM_FILE"
|
|
}
|
|
|
|
resource "google_project_iam_binding" "sa_viewer" {
|
|
project = var.project_id
|
|
role = "roles/viewer"
|
|
|
|
members = [
|
|
"serviceAccount:${google_service_account.service_account.email}",
|
|
]
|
|
}
|
|
|
|
# Ajout sécurité : OS Login
|
|
data "google_client_openid_userinfo" "me" {}
|
|
|
|
resource "google_os_login_ssh_public_key" "ssh_key" {
|
|
user = data.google_client_openid_userinfo.me.email
|
|
project = var.project_id
|
|
key = file(var.ssh_public_key_path)
|
|
}
|