Skip to content

feat: add check block to warn about blob CSI driver subnet drift (fixes #424)#743

Merged
lonegunmanb merged 1 commit intomainfrom
fix/issue-424-blob-driver-drift-check
Mar 20, 2026
Merged

feat: add check block to warn about blob CSI driver subnet drift (fixes #424)#743
lonegunmanb merged 1 commit intomainfrom
fix/issue-424-blob-driver-drift-check

Conversation

@lonegunmanb
Copy link
Copy Markdown
Member

Summary

When storage_profile_blob_driver_enabled is true, the AKS Blob CSI driver may automatically add a Microsoft.Storage service endpoint to the subnet out-of-band when a blob NFS PersistentVolumeClaim is created. This causes Terraform state drift — subsequent terraform plan detects the out-of-band change and attempts to remove the service endpoint.

This PR adds a Terraform check block that warns users (without blocking operations) when their subnet does not have Microsoft.Storage declared in service_endpoints, so they can proactively add it to prevent drift.

Changes

  • Added data.azurerm_subnet.blob_driver_check — conditional data source that only queries the subnet when storage_profile_enabled, storage_profile_blob_driver_enabled are both true and vnet_subnet is provided.
  • Added check "blob_driver_subnet_service_endpoint" — produces a warning if the subnet lacks the Microsoft.Storage service endpoint.

Impact

  • Non-breaking: The check block only produces warnings, never errors.
  • No new variables: Uses existing storage_profile_enabled, storage_profile_blob_driver_enabled, and vnet_subnet variables.
  • Version compatible: check blocks are supported since Terraform 1.5; the module already requires >= 1.9.
  • Minimal API overhead: The data.azurerm_subnet lookup only runs when conditions are met.

Verification

  • terraform validate: Passed
  • Drift scenario manually reproduced and confirmed in a prior experiment (see issue comments)

Fixes #424

#424)

When storage_profile_blob_driver_enabled is true, the AKS Blob CSI driver
may automatically add a Microsoft.Storage service endpoint to the subnet
out-of-band, causing Terraform state drift. This adds a check block that
warns users to proactively declare the service endpoint on their subnet.

The check block uses a conditional data.azurerm_subnet lookup and only
triggers when storage_profile_enabled, storage_profile_blob_driver_enabled
are both true and vnet_subnet is provided. It produces a warning (not an
error), so it is non-breaking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lonegunmanb
Copy link
Copy Markdown
Member Author

LGTM! Clean, non-breaking addition that proactively warns about known Azure Blob CSI driver behavior causing Terraform state drift. Implementation is solid: properly gated count condition, reuses existing vars/locals, check block only warns, good error message with actionable fix and issue reference. All CI checks passed including E2E tests. Ready for maintainer merge.

Copy link
Copy Markdown
Collaborator

@jiaweitao001 jiaweitao001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lonegunmanb lonegunmanb merged commit b1fdae8 into main Mar 20, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Azure Module Kanban Mar 20, 2026
@lonegunmanb lonegunmanb deleted the fix/issue-424-blob-driver-drift-check branch March 20, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Risk of Terraform state drift when storage_profile_blob_driver_enabled is true

2 participants