Skip to content

Commit

Permalink
fix: Output values directly from resource (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkrysmann authored Feb 3, 2022
1 parent 5afef97 commit cb0f7f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ locals {
org_billing = var.grant_billing_role && var.billing_account_id == "" && var.org_id != ""
prefix = var.prefix != "" ? "${var.prefix}-" : ""
xpn = var.grant_xpn_roles && var.org_id != ""
service_accounts_list = [for name in var.names : google_service_account.service_accounts[name]]
service_accounts_list = [for account in google_service_account.service_accounts : account]
emails_list = [for account in local.service_accounts_list : account.email]
iam_emails_list = [for email in local.emails_list : "serviceAccount:${email}"]
names = toset(var.names)
Expand Down
10 changes: 5 additions & 5 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

output "service_account" {
description = "Service account resource (for single use)."
value = local.service_accounts_list[0]
value = try(local.service_accounts_list[0], null)
}

output "email" {
description = "Service account email (for single use)."
value = local.emails_list[0]
value = try(local.emails_list[0], null)
}

output "iam_email" {
description = "IAM-format service account email (for single use)."
value = local.iam_emails_list[0]
value = try(local.iam_emails_list[0], null)
}

output "key" {
Expand All @@ -47,12 +47,12 @@ output "service_accounts_map" {

output "emails" {
description = "Service account emails by name."
value = zipmap(var.names, local.emails_list)
value = zipmap(local.service_accounts_list[*].name, local.emails_list)
}

output "iam_emails" {
description = "IAM-format service account emails by name."
value = zipmap(var.names, local.iam_emails_list)
value = zipmap(local.service_accounts_list[*].name, local.iam_emails_list)
}

output "emails_list" {
Expand Down

0 comments on commit cb0f7f0

Please sign in to comment.