fix: Self Service state reading for Jamf Pro policies #937
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.
Pull Request Description
Summary
Fix Self Service state reading for Jamf Pro policies by correctly handling default values and missing field assignments. This prevents unwanted diffs when the Self Service block is not explicitly defined in Terraform configuration but Jamf Pro returns values during state refresh.
Issue Reference
N/A
Motivation and Context
self_service_display_nameto the policy nameinstall_button_textfield is often set to an empty string by the API when not explicitly set via Terraform, but the schema default is "Install"reinstall_button_textfield was not being tracked in state, causing potential state driftDependencies
Type of Change
Please mark the relevant option with an
x:Testing
Quality Checklist
Screenshots/Recordings (if appropriate)
N/A
Additional Notes
This fix addresses the root cause of unwanted Self Service diffs when policies are imported without explicit Self Service configuration. The changes handle two special cases:
self_service_display_nameequals the policy name (auto-populated by Jamf Pro GUI)install_button_textis an empty string (API created policies not explicitly defining Self Service config)Both are treated as defaults and do not trigger state changes. The fix also adds the missing
reinstall_button_textfield assignment to ensure all fields are properly tracked in state.