Skip to content

Commit 1141f5c

Browse files
authored
fix(autopilot): preserve hybrid_azure_ad_join_skip_connectivity_check for azure ad joined profiles (#888)
1 parent 8b6c206 commit 1141f5c

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

internal/services/resources/device_management/graph_beta/windows_autopilot_deployment_profile/state.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,20 @@ func MapRemoteResourceStateToTerraform(ctx context.Context, data *WindowsAutopil
4444
data.DeviceJoinType = types.StringNull()
4545
}
4646

47-
// Check if this is an ActiveDirectoryWindowsAutopilotDeploymentProfile and handle hybrid Azure AD join setting
47+
// Handle hybrid_azure_ad_join_skip_connectivity_check
48+
// This property only exists on activeDirectoryWindowsAutopilotDeploymentProfile (Hybrid AD joined)
49+
// For azureADWindowsAutopilotDeploymentProfile (Azure AD joined), the API does not return this field
4850
if adResource, ok := remoteResource.(graphmodels.ActiveDirectoryWindowsAutopilotDeploymentProfileable); ok {
51+
// Hybrid AD joined profile - read from the typed property
4952
data.HybridAzureADJoinSkipConnectivityCheck = convert.GraphToFrameworkBool(adResource.GetHybridAzureADJoinSkipConnectivityCheck())
5053
} else {
51-
// For Azure AD profiles, this field is not applicable but we should preserve the configured value
52-
// to avoid Terraform inconsistency errors. The field is not sent to the API for Azure AD profiles.
53-
if !data.HybridAzureADJoinSkipConnectivityCheck.IsUnknown() {
54-
// Keep the existing value from configuration
55-
} else {
56-
data.HybridAzureADJoinSkipConnectivityCheck = types.BoolNull()
54+
// Azure AD joined profile - this field doesn't exist in the API response
55+
// Keep the configured value from state to avoid inconsistency errors
56+
// The validator ensures this is always false for Azure AD joined profiles
57+
if data.HybridAzureADJoinSkipConnectivityCheck.IsNull() || data.HybridAzureADJoinSkipConnectivityCheck.IsUnknown() {
58+
data.HybridAzureADJoinSkipConnectivityCheck = types.BoolValue(false)
5759
}
60+
// Otherwise preserve the existing value from config/state
5861
}
5962

6063
if deviceType := remoteResource.GetDeviceType(); deviceType != nil {

internal/services/resources/device_management/graph_beta/windows_autopilot_deployment_profile/tests/responses/validate_create/post_windows_autopilot_deployment_profile_04_hololens.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"roleScopeTagIds": ["0"],
1313
"deviceType": "holoLens",
1414
"deviceJoinType": "azureADJoined",
15-
"hybridAzureADJoinSkipConnectivityCheck": false,
1615
"outOfBoxExperienceSetting": {
1716
"privacySettingsHidden": true,
1817
"eulaHidden": true,

internal/services/resources/device_management/graph_beta/windows_autopilot_deployment_profile/tests/responses/validate_create/post_windows_autopilot_deployment_profile_success.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"roleScopeTagIds": ["0", "1"],
1313
"deviceType": "windowsPc",
1414
"deviceJoinType": "azureADJoined",
15-
"hybridAzureADJoinSkipConnectivityCheck": false,
1615
"outOfBoxExperienceSetting": {
1716
"privacySettingsHidden": true,
1817
"eulaHidden": true,

0 commit comments

Comments
 (0)