Skip to content

Commit

Permalink
Merge pull request #14 from terraform-google-modules/ludo-zipmap-outp…
Browse files Browse the repository at this point in the history
…uts-fix

Make outputs work on names variable change
  • Loading branch information
ludoo authored Nov 9, 2019
2 parents 2db8e39 + 4ff2275 commit 3b83f7d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to

## [Unreleased]

## [2.0.2] - 2019-10-09

### Fixed

- Fix outputs on `names` variable element removal/change [#14]

## [2.0.1] - 2019-09-13

### Changed
Expand Down Expand Up @@ -44,12 +50,16 @@ and this project adheres to

- Initial release. [#1]

[Unreleased]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v2.0.0...HEAD
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v2.0.2...HEAD
[2.0.2]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v1.0.0...v2.0.0
[1.0.0]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v0.1.1...v1.0.0
[0.1.1]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/terraform-google-modules/terraform-google-service-accounts/releases/tag/v0.1.0

[#14]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/14
[#13]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/13
[#9]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/9
[#3]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/3
[#1]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/1
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @morgante @aaron-lane @ludoo @averbuks
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ 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 != ""
iam_emails = [for s in google_service_account.service_accounts : "serviceAccount:${s.email}"]
emails = [for account in google_service_account.service_accounts : account.email]
iam_emails = [for email in local.emails : "serviceAccount:${email}"]
}

# create service accounts
Expand Down
13 changes: 8 additions & 5 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ output "service_accounts" {

output "emails" {
description = "Service account emails."
value = zipmap(var.names, google_service_account.service_accounts[*].email)
value = zipmap(var.names, slice(local.emails, 0, length(var.names)))
}

output "iam_emails" {
description = "IAM-format service account emails."
value = zipmap(var.names, local.iam_emails)
value = zipmap(var.names, slice(local.iam_emails, 0, length(var.names)))
}

output "emails_list" {
description = "Service account emails."
value = google_service_account.service_accounts[*].email
value = local.emails
}

output "iam_emails_list" {
description = "IAM-format service account emails."
value = [for s in google_service_account.service_accounts : "serviceAccount:${s.email}"]
value = local.iam_emails
}

data "template_file" "keys" {
Expand All @@ -71,5 +71,8 @@ data "template_file" "keys" {
output "keys" {
description = "Map of service account keys."
sensitive = true
value = zipmap(var.names, data.template_file.keys[*].rendered)
value = zipmap(
var.names,
slice(data.template_file.keys[*].rendered, 0, length(var.names))
)
}

0 comments on commit 3b83f7d

Please sign in to comment.