Merge pull request #294 from terraform-google-modules/jccb/static-sa-output

Compute service account email statically
This commit is contained in:
Julio Castillo 2021-08-10 11:10:36 +02:00 committed by GitHub
commit fc3fbcd75e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -56,8 +56,10 @@ locals {
? google_service_account_key.key["1"]
: map("", null)
, {})
prefix = var.prefix != null ? "${var.prefix}-" : ""
resource_iam_email = "serviceAccount:${local.service_account.email}"
prefix = var.prefix != null ? "${var.prefix}-" : ""
resource_email_static = "${local.prefix}${var.name}@${var.project_id}.iam.gserviceaccount.com"
resource_iam_email_static = "serviceAccount:${local.resource_email_static}"
resource_iam_email = "serviceAccount:${local.service_account.email}"
service_account = (
var.service_account_create
? try(google_service_account.service_account.0, null)

View File

@ -21,12 +21,18 @@ output "service_account" {
output "email" {
description = "Service account email."
value = local.service_account.email
value = local.resource_email_static
depends_on = [
local.service_account
]
}
output "iam_email" {
description = "IAM-format service account email."
value = local.resource_iam_email
value = local.resource_iam_email_static
depends_on = [
local.service_account
]
}
output "key" {