
# 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")
}
