fix: use dynamic iap block to prevent perpetual no-op diff#586
Open
ianb-pomelo wants to merge 1 commit into
Open
fix: use dynamic iap block to prevent perpetual no-op diff#586ianb-pomelo wants to merge 1 commit into
ianb-pomelo wants to merge 1 commit into
Conversation
When `iap_config` is not provided in a backend configuration, the static
`iap` block sets `oauth2_client_id` to `null`. However, the GCP API
returns `" "` (a single space) for unset `oauth2_client_id` values,
causing Terraform to detect a diff on every plan:
~ iap {
- oauth2_client_id = " " -> null
}
By making the `iap` block dynamic, it is only rendered when `iap_config`
is explicitly provided. This eliminates the perpetual no-op diff for
backends that don't use IAP, while preserving existing behavior for
backends that do.
Author
|
/gcbrun |
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Author
|
Still would like this if possible, it causes a good amount of churn in our state for no reason |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
iap_configis not provided in a backend configuration, the staticiapblock setsoauth2_client_idtonull. However, the GCP API returns" "(a single space) for unsetoauth2_client_idvalues, causing Terraform to detect a diff on every plan:This results in a perpetual no-op update to
google_compute_backend_serviceresources that don't use IAP.Solution
Make the
iapblock dynamic so it is only rendered wheniap_configis explicitly provided. Wheniap_configis absent, the block is omitted entirely, and Terraform no longer tries to reconcilenullvs the" "returned by the API.Changes
The same change is applied in all 4 locations where the
iapblock appears:main.tfmodules/serverless_negs/main.tfmodules/dynamic_backends/main.tfautogen/main.tf.tmplBefore:
After:
Backward Compatibility
This is a non-breaking change:
iap_configset behave identically to beforeiap_configsimply stop producing the phantom diffRelated: #451, hashicorp/terraform-provider-google#16585