forked from pierront/but3-iac
Problème avec Compute : subnet
This commit is contained in:
28
tp-cloud/terraform/modules/iam/main.tf
Normal file
28
tp-cloud/terraform/modules/iam/main.tf
Normal file
@@ -0,0 +1,28 @@
|
||||
resource "google_service_account" "terraform_sa" {
|
||||
account_id = "${var.project}-tf-sa"
|
||||
project = var.project
|
||||
display_name = "Terraform service account for ${var.project}"
|
||||
}
|
||||
|
||||
resource "google_project_iam_member" "sa_compute_admin" {
|
||||
project = var.project
|
||||
role = "roles/compute.instanceAdmin.v1"
|
||||
member = "serviceAccount:${google_service_account.terraform_sa.email}"
|
||||
}
|
||||
|
||||
resource "google_project_iam_member" "sa_os_login" {
|
||||
project = var.project
|
||||
role = "roles/compute.osLogin"
|
||||
member = "serviceAccount:${google_service_account.terraform_sa.email}"
|
||||
}
|
||||
|
||||
resource "google_service_account_key" "terraform_sa_key" {
|
||||
service_account_id = google_service_account.terraform_sa.name
|
||||
}
|
||||
|
||||
resource "google_project_metadata" "oslogin" {
|
||||
project = var.project
|
||||
metadata = {
|
||||
enable-oslogin = "TRUE"
|
||||
}
|
||||
}
|
||||
9
tp-cloud/terraform/modules/iam/outputs.tf
Normal file
9
tp-cloud/terraform/modules/iam/outputs.tf
Normal file
@@ -0,0 +1,9 @@
|
||||
output "service_account_email" {
|
||||
value = google_service_account.terraform_sa.email
|
||||
}
|
||||
|
||||
output "service_account_key" {
|
||||
value = google_service_account_key.terraform_sa_key.private_key
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
5
tp-cloud/terraform/modules/iam/variables.tf
Normal file
5
tp-cloud/terraform/modules/iam/variables.tf
Normal file
@@ -0,0 +1,5 @@
|
||||
variable "project" {
|
||||
description = "GCP project id"
|
||||
type = string
|
||||
project = "projet-hugo-478713"
|
||||
}
|
||||
Reference in New Issue
Block a user