Skip to content

Commit 7083802

Browse files
committed
fix(workload-identity): resolve inconsistent conditional result types in output
Fixes #1112 When use_existing_gcp_sa is unknown at plan time, Terraform fails with 'Inconsistent conditional result types' because data.google_service_account and google_service_account.cluster_service_account have different object types. The fix uses one(concat(...)) instead of a conditional expression: - Only one list will ever have elements (based on count conditions) - concat() avoids type comparison between the two different resource types - one() extracts the single element from the concatenated list This approach is type-safe and works regardless of when use_existing_gcp_sa is known.
1 parent a04f3ee commit 7083802

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

modules/workload-identity/output.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,10 @@ output "gcp_service_account_name" {
4141

4242
output "gcp_service_account" {
4343
description = "GCP service account."
44-
value = var.use_existing_gcp_sa ? data.google_service_account.cluster_service_account[0] : google_service_account.cluster_service_account[0]
44+
# Use one(concat(...)) instead of conditional to avoid type mismatch between
45+
# data source and resource (one will always be empty based on count)
46+
value = one(concat(
47+
data.google_service_account.cluster_service_account,
48+
google_service_account.cluster_service_account
49+
))
4550
}

0 commit comments

Comments
 (0)