TP_Terraform/terraform/modules/iam/main.tf
2024-12-06 16:35:48 +01:00

25 lines
718 B
HCL

resource "google_service_account" "service_account" {
account_id = "terraform"
display_name = "terraform"
}
resource "google_service_account_key" "service_account" {
service_account_id = google_service_account.service_account.name
public_key_type = "TYPE_X509_PEM_FILE"
}
resource "google_project_iam_binding" "service_account_roles" {
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" "add_my_key" {
project = var.project_id
user = data.google_client_openid_userinfo.me.email
key = file("~/.ssh/id_ed25519.pub")
}