Skip to content

Fix IAP oauth2_client_id perpetual diff in BackendService and RegionBackendService#16639

Merged
trodge merged 1 commit intoGoogleCloudPlatform:mainfrom
178inaba:fix/iap-oauth2-client-id-perpetual-diff
Mar 9, 2026
Merged

Fix IAP oauth2_client_id perpetual diff in BackendService and RegionBackendService#16639
trodge merged 1 commit intoGoogleCloudPlatform:mainfrom
178inaba:fix/iap-oauth2-client-id-perpetual-diff

Conversation

@178inaba
Copy link
Copy Markdown
Contributor

@178inaba 178inaba commented Mar 8, 2026

Fixes hashicorp/terraform-provider-google#26378

Problem

When using google_compute_backend_service or google_compute_region_backend_service with IAP enabled and then disabling IAP by removing oauth2_client_id and oauth2_client_secret, every terraform plan produces a perpetual diff:

~ iap {
  - oauth2_client_id = "1234-xxxx.apps.googleusercontent.com" -> null
  }

This happens because the provider's expand function skips sending empty values for oauth2ClientId (guarded by IsEmptyValue), so the API retains the old value and the diff reappears on every plan.

Root Cause

There is an asymmetry between oauth2ClientId and oauth2ClientSecret in the resource YAML definitions. oauth2ClientSecret has send_empty_value: true (added during the handwritten-to-generated migration in #7463), but oauth2ClientId does not. This became a problem when #9581 removed required: true from both fields.

Fix

Added send_empty_value: true to oauth2ClientId in both BackendService.yaml and RegionBackendService.yaml, matching the existing oauth2ClientSecret behavior. A unit test is also included to guard against future regressions.

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

compute: fixed perpetual diff for `oauth2_client_id` in `iap` block of `google_compute_backend_service` and `google_compute_region_backend_service` when disabling IAP

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Mar 8, 2026
@github-actions github-actions Bot requested a review from trodge March 8, 2026 06:43
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 8, 2026

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@trodge, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@178inaba 178inaba force-pushed the fix/iap-oauth2-client-id-perpetual-diff branch from df412ee to 09c6912 Compare March 8, 2026 07:15
@modular-magician modular-magician added service/compute-l7-load-balancer and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Mar 9, 2026
@modular-magician
Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 2 files changed, 2 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 2 files changed, 2 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 3 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 1380
Passed tests: 1288
Skipped tests: 90
Affected tests: 2

Click here to see the affected service packages
  • compute

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccComputeBackendService_updateIAPEnabled
  • TestAccComputeRegionBackendService_updateIAPEnabled

Get to know how VCR tests work

@modular-magician
Copy link
Copy Markdown
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccComputeBackendService_updateIAPEnabled [Debug log]
TestAccComputeRegionBackendService_updateIAPEnabled [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🟢 All tests passed!

View the build log or the debug log for each test

@trodge trodge added this pull request to the merge queue Mar 9, 2026
Merged via the queue into GoogleCloudPlatform:main with commit b6925fe Mar 9, 2026
28 checks passed
aditikumarii-google pushed a commit to aditikumarii-google/magic-modules that referenced this pull request Mar 10, 2026
@178inaba 178inaba deleted the fix/iap-oauth2-client-id-perpetual-diff branch March 11, 2026 10:02
ChuAmberZhang pushed a commit to ChuAmberZhang/magic-modules that referenced this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google_compute_backend_service: perpetual diff on oauth2_client_id after disabling IAP

3 participants