forked from pierront/but3-iac
commit
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,2 +1,4 @@
|
||||
# À vous de définir :
|
||||
# - project_id (string)
|
||||
variable "project_id" {
|
||||
description = "ID du projet GCP dans lequel appliquer les règles IAM"
|
||||
type = string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user