fix(grouppolicy): enable import for text/boolean/multi-text value resources #866
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.
Summary
This PR fixes the import functionality for Group Policy Administrative Template (ADMX) resources by implementing composite ID parsing and API-based metadata resolution. Previously, importing
group_policy_text_value,group_policy_boolean_value, andgroup_policy_multi_text_valueresources failed because the resolver required metadata fields (policy_name,class_type,category_path) that were not populated during import.Issue Reference
Fixes #867
Motivation and Context
ImportStatePassthroughID()which only set theidfield, leaving required metadata fields null. This caused the Read function's resolver to fail with "provide policy_name, class_type, and category_path for auto-discovery"configID/definitionValueID/presentationValueID) with a helper function that fetches metadata from the Microsoft Graph API during importDependencies
$expand=definitionquery parameter support in Graph API (already available)Type of Change
Please mark the relevant option with an
x:Changes Made
Files Modified
group_policy_text_valueresource:resource.go: UpdatedImportState()to parse composite ID formatcrud.go: EnhancedRead()to detect import scenarios and call metadata helperimport.go: CreatedpopulateMetadataFromAPI()helper functionimport.sh: Updated example to show composite ID formatSimilar changes applied to:
group_policy_boolean_value(same pattern)group_policy_multi_text_value(same pattern)Key Implementation Details
configID/definitionValueID/presentationValueIDGET /deviceManagement/groupPolicyConfigurations/{id}/definitionValueswith$expand=definitionpolicy_name(displayName),class_type,category_path, and optionallypresentation_idTesting
Test Environment:
Quality Checklist
Additional Notes
This implementation follows common Terraform provider patterns seen in AWS, Azure, and GCP providers for handling complex import scenarios. The approach:
$expandAn example showing importing Dell ADMX Template Update Settings value.