Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workload identity gcp_service_account return value incorrect in 16.1.0 #1006

Closed
jackwhelpton opened this issue Sep 24, 2021 · 3 comments · Fixed by #1009
Closed

Workload identity gcp_service_account return value incorrect in 16.1.0 #1006

jackwhelpton opened this issue Sep 24, 2021 · 3 comments · Fixed by #1009
Labels
bug Something isn't working P1 highest priority issues triaged Scoped and ready for work

Comments

@jackwhelpton
Copy link
Contributor

jackwhelpton commented Sep 24, 2021

Running with 16.1.0, the following code:

module.workload_identity_rcp[local.api_sa].gcp_service_account.account_id

yields the error:

This value does not have any attributes.

This was working fine in 16.0.1 (and prior).

For completeness, here's the module call:

module "workload_identity_rcp" {
  source  = "terraform-google-modules/kubernetes-engine/google//modules/workload-identity"
  version = "16.0.1"

  providers = {
    kubernetes = kubernetes.rcp
  }

  for_each = toset([local.api_sa, local.component_sa, local.traffic_sa])

  name       = each.value
  namespace  = kubernetes_namespace.rcp.metadata[0].name
  project_id = module.rcp-prodsci-cls-rcp-dev.project_id
}

so I'm not setting any of the use_existing_* flags, just letting the module create the GSA and KSA.

@jackwhelpton
Copy link
Contributor Author

I've dug in a bit and found the bug here:

data "google_service_account" "cluster_service_account" {
  count = var.use_existing_gcp_sa ? 1 : 0

  account_id = local.gcp_given_name
  project    = var.project_id
}

so the service account details are only looked up if it was explicitly supplied, and not if it was created by the module. This is a breaking change as it means the output variable is null in those cases.

@jackwhelpton
Copy link
Contributor Author

Looks like a regression caused by #974

@morgante
Copy link
Contributor

Thanks for the report, this is indeed a bug. We should fix it by making the output either reference the data source (if using an existing SA) or the resource (if not).

@morgante morgante added bug Something isn't working P1 highest priority issues triaged Scoped and ready for work labels Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 highest priority issues triaged Scoped and ready for work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants