Create IAP for nomad#2573
Conversation
PR SummaryMedium Risk Overview Potential issues: IAP enablement only checks Reviewed by Cursor Bugbot for commit 6c4296f. Bugbot is set up for automated code reviews on this repo. Configure here. |
❌ 3 Tests Failed:
View the full list of 3 ❄️ flaky test(s)
To view more test analytics, go to the Test Analytics Dashboard |
| iap = var.nomad_iap_oauth2_client_id != null ? { | ||
| oauth2_client_id = var.nomad_iap_oauth2_client_id | ||
| oauth2_client_secret = var.nomad_iap_oauth2_client_secret | ||
| } : null |
There was a problem hiding this comment.
The IAP configuration for the Nomad backend only checks for the presence of the OAuth2 client ID. If a client ID is provided but the client secret is missing, the backend service resource will attempt to enable IAP with a null secret, which will cause a failure during the Terraform apply phase. The condition should ensure both the client ID and secret are present before enabling the IAP block.
iap = (var.nomad_iap_oauth2_client_id != null && var.nomad_iap_oauth2_client_secret != null) ? {
oauth2_client_id = var.nomad_iap_oauth2_client_id
oauth2_client_secret = var.nomad_iap_oauth2_client_secret
} : null
|
|
||
| # IAP IAM binding for Nomad backend | ||
| resource "google_iap_web_backend_service_iam_binding" "nomad_iap" { | ||
| count = var.nomad_iap_oauth2_client_id != null && length(var.nomad_iap_members) > 0 ? 1 : 0 |
There was a problem hiding this comment.
The IAM binding for IAP is created based on the presence of the client ID and a non-empty members list. However, if the client ID is provided but the client secret is missing, the backend service will fail to enable IAP (or fail to apply), leading to an inconsistent state where an IAM binding exists for a feature that is not correctly configured on the target resource. This condition should be updated to match the logic used for enabling IAP on the backend service.
count = var.nomad_iap_oauth2_client_id != null && var.nomad_iap_oauth2_client_secret != null && length(var.nomad_iap_members) > 0 ? 1 : 0
| enabled = true | ||
| oauth2_client_id = iap.value["oauth2_client_id"] | ||
| oauth2_client_secret = iap.value["oauth2_client_secret"] | ||
| } |
There was a problem hiding this comment.
IAP blocks Nomad API clients
High Severity
IAP is enabled on the same nomad.${domain} endpoint used by the Terraform nomad provider, but that provider is only configured with the Nomad ACL token. Once active, Terraform Nomad job management hits the IAP login barrier and fails.
Reviewed by Cursor Bugbot for commit 1db68f2. Configure here.
| project = var.gcp_project_id | ||
| web_backend_service = google_compute_backend_service.default["nomad"].name | ||
| role = "roles/iap.httpsResourceAccessor" | ||
| members = var.nomad_iap_members |
There was a problem hiding this comment.
IAP can enable without access
Medium Severity
IAP turns on when nomad_iap_oauth2_client_id is set, but the access binding is skipped when nomad_iap_members is empty. That can apply successfully while leaving the Nomad UI with no Terraform-managed IAP users.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 1db68f2. Configure here.
| web_backend_service = google_compute_backend_service.default["nomad"].name | ||
| role = "roles/iap.httpsResourceAccessor" | ||
| members = var.nomad_iap_members | ||
| } |
There was a problem hiding this comment.
IAP API is never enabled
Medium Severity
google_iap_web_backend_service_iam_binding uses the IAP API, but the GCP init module never enables iap.googleapis.com. Enabling Nomad IAP can fail at apply time in fresh projects.
Reviewed by Cursor Bugbot for commit 1db68f2. Configure here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 4 total unresolved issues (including 3 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6c4296f. Configure here.
| iap = var.nomad_iap_oauth2_client_id != null ? { | ||
| oauth2_client_id = var.nomad_iap_oauth2_client_id | ||
| oauth2_client_secret = var.nomad_iap_oauth2_client_secret | ||
| } : null |
There was a problem hiding this comment.
Sensitive backend map breaks plans
High Severity
Including nomad_iap_oauth2_client_secret in the iap block within local.backends makes the collection sensitive. Terraform's for_each cannot process sensitive values when creating google_compute_backend_service resources, causing plan failures when Nomad IAP is enabled.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 6c4296f. Configure here.
|
Turns out it's tedious to get nomad's terraform provider to communicate through IAP, and really tedious to convince terraform that IAP is optional, but not necessary. Going to punt on this. |


No description provided.