azurerm_kubernetes_cluster - fix drift detection for default_node_pool optional fields (max_pods, os_disk_type, host_encryption_enabled, upgrade_settings) #30608
+75
−21
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.
Community Note
Description
This PR fixes an issue where the
azurerm_kubernetes_cluster
resource could show “No changes” despite configuration drift in thedefault_node_pool
block.The bug was caused by incomplete state flattening of optional fields. When these fields were set server-side but omitted from state, Terraform would not detect drift.
This change updates the flattening logic to correctly handle the following optional fields:
max_pods
os_disk_type
host_encryption_enabled
upgrade_settings
Not Included
The original bug report mentioned
only_critical_addons_enabled
, but this PR does not address it. That field does not appear in ARM API responses for eitheragentpools
ormanagedclusters
(2025-05-01
), and we have not observed server-side drift. To avoid false positives, it is deferred for a future PR if API behavior changes.PR Checklist
Changes to existing Resource / Data Source
Testing
This PR adds acceptance test coverage to ensure that optional fields in the
default_node_pool
block are correctly flattened into state to prevent configuration drift.TestAccKubernetesCluster_defaultNodePool_StateFlattening_Present
, verifying thatmax_pods
andupgrade_settings
are persisted in state. → Test Loghost_encryption_enabled
).os_disk_type
was not included in acceptance tests, since exercising it requires selecting a specific OS SKU, which could introduce flakiness in CI. This can be validated in a full subscription environment.Change Log
Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.
azurerm_kubernetes_cluster
– fixed an issue wheredefault_node_pool
would not detect drift in themax_pods
,os_disk_type
,host_encryption_enabled
, andupgrade_settings
properties [AKS default_node_pool: Terraform shows "No changes" despite systematic configuration drift across multiple critical settings #30390]This is a (please select all that apply):
Related Issue(s)
Fixes #30390
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the provider.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Note
If this PR changes meaningfully during the course of review please update the title and description as required.