forked from pierront/but3-iac
tp
This commit is contained in:
32
terraform/modules/iam/main.tf
Normal file
32
terraform/modules/iam/main.tf
Normal file
@@ -0,0 +1,32 @@
|
||||
resource "google_service_account" "service_account" {
|
||||
account_id = "terraform"
|
||||
display_name = "terraform"
|
||||
}
|
||||
|
||||
|
||||
resource "google_service_account_key" "mykey" {
|
||||
service_account_id = google_service_account.service_account.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
|
||||
key = file("~/.ssh/id_ed25519.pub")
|
||||
project = var.project_id
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
10
terraform/modules/iam/outputs.tf
Normal file
10
terraform/modules/iam/outputs.tf
Normal file
@@ -0,0 +1,10 @@
|
||||
output "email" {
|
||||
description = "Service account email."
|
||||
value = google_service_account.service_account.email
|
||||
}
|
||||
|
||||
output "key" {
|
||||
description = "Service account private key."
|
||||
sensitive = true
|
||||
value = google_service_account_key.mykey.private_key
|
||||
}
|
||||
7
terraform/modules/iam/variables.tf
Normal file
7
terraform/modules/iam/variables.tf
Normal file
@@ -0,0 +1,7 @@
|
||||
variable "project_id" {
|
||||
description = "ID du projet GCP"
|
||||
type = string
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user