Skip to content

Commit 3b83f7d

Browse files
authored
Merge pull request #14 from terraform-google-modules/ludo-zipmap-outputs-fix
Make outputs work on names variable change
2 parents 2db8e39 + 4ff2275 commit 3b83f7d

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to
99

1010
## [Unreleased]
1111

12+
## [2.0.2] - 2019-10-09
13+
14+
### Fixed
15+
16+
- Fix outputs on `names` variable element removal/change [#14]
17+
1218
## [2.0.1] - 2019-09-13
1319

1420
### Changed
@@ -44,12 +50,16 @@ and this project adheres to
4450

4551
- Initial release. [#1]
4652

47-
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v2.0.0...HEAD
53+
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v2.0.2...HEAD
54+
[2.0.2]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v2.0.1...v2.0.2
55+
[2.0.1]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v2.0.0...v2.0.1
4856
[2.0.0]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v1.0.0...v2.0.0
4957
[1.0.0]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v0.1.1...v1.0.0
5058
[0.1.1]: https://github.com/terraform-google-modules/terraform-google-service-accounts/compare/v0.1.0...v0.1.1
5159
[0.1.0]: https://github.com/terraform-google-modules/terraform-google-service-accounts/releases/tag/v0.1.0
5260

61+
[#14]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/14
62+
[#13]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/13
5363
[#9]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/9
5464
[#3]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/3
5565
[#1]: https://github.com/terraform-google-modules/terraform-google-service-accounts/pull/1

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @morgante @aaron-lane @ludoo @averbuks

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ locals {
1919
org_billing = var.grant_billing_role && var.billing_account_id == "" && var.org_id != ""
2020
prefix = var.prefix != "" ? "${var.prefix}-" : ""
2121
xpn = var.grant_xpn_roles && var.org_id != ""
22-
iam_emails = [for s in google_service_account.service_accounts : "serviceAccount:${s.email}"]
22+
emails = [for account in google_service_account.service_accounts : account.email]
23+
iam_emails = [for email in local.emails : "serviceAccount:${email}"]
2324
}
2425

2526
# create service accounts

outputs.tf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ output "service_accounts" {
4141

4242
output "emails" {
4343
description = "Service account emails."
44-
value = zipmap(var.names, google_service_account.service_accounts[*].email)
44+
value = zipmap(var.names, slice(local.emails, 0, length(var.names)))
4545
}
4646

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

5252
output "emails_list" {
5353
description = "Service account emails."
54-
value = google_service_account.service_accounts[*].email
54+
value = local.emails
5555
}
5656

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

6262
data "template_file" "keys" {
@@ -71,5 +71,8 @@ data "template_file" "keys" {
7171
output "keys" {
7272
description = "Map of service account keys."
7373
sensitive = true
74-
value = zipmap(var.names, data.template_file.keys[*].rendered)
74+
value = zipmap(
75+
var.names,
76+
slice(data.template_file.keys[*].rendered, 0, length(var.names))
77+
)
7578
}

0 commit comments

Comments
 (0)