read aks with needed properties and read them locally for des role assignment#1079
Merged
zqingqing1 merged 12 commits intomainfrom Feb 28, 2026
Merged
read aks with needed properties and read them locally for des role assignment#1079zqingqing1 merged 12 commits intomainfrom
zqingqing1 merged 12 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR mitigates a Terraform azurerm provider panic when reading full AKS managed cluster state (notably around nil agent pool profile fields) by avoiding the azurerm_kubernetes_cluster data source where only a small subset of identity fields/IDs are needed for role assignments.
Changes:
- Replaced AKS read for DES role assignments with an
azapi_resourcedata read that exports onlyidentityandproperties.identityProfile. - Derived AKS and Resource Group IDs locally (via subscription ID + names) to avoid full AKS/RG data-source reads in the VM module.
- Added an
aks-climoduleversions.tfdeclaring azurerm/azapi as required providers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| modules/terraform/azure/virtual-machine/main.tf | Builds RG/AKS resource IDs locally and uses them for VM AKS integration role assignments, removing full AKS/RG data-source reads. |
| modules/terraform/azure/aks-cli/versions.tf | Declares required Terraform and providers for aks-cli (azurerm + azapi). |
| modules/terraform/azure/aks-cli/main.tf | Uses azapi_resource to fetch only the minimal AKS identity payload needed for DES role assignments and adds defensive parsing + clearer failure errors. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
xinWeiWei24
reviewed
Feb 27, 2026
xinWeiWei24
approved these changes
Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR is mainly to address this issue: https://dev.azure.com/akstelescope/telescope/_build/results?buildId=55671&view=results
when getting aks and if some properties is nil at agent pool profile , and flatten them into managed cluster could see nil pointer panic. In this PR, we only need to get the properties we care without getting whole MC body.
│ Error: Request cancelled
│
│ with module.aks-cli["nap"].data.azurerm_kubernetes_cluster.aks[0],
│ on aks-cli/main.tf line 300, in data "azurerm_kubernetes_cluster" "aks":
│ 300: data "azurerm_kubernetes_cluster" "aks" {
│
│ The plugin.(*GRPCProvider).ReadDataSource request was cancelled.
╵
Stack trace from the terraform-provider-azurerm_v4.42.0_x5 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x55f413b]
goroutine 4768 [running]:
github.com/hashicorp/terraform-provider-azurerm/internal/services/containers.flattenKubernetesClusterDataSourceAgentPoolProfiles(0xc000017170?)
github.com/hashicorp/terraform-provider-azurerm/internal/services/containers/kubernetes_cluster_data_source.go:1232 +0x85b
github.com/hashicorp/terraform-provider-azurerm/internal/services/containers.dataSourceKubernetesClusterRead(0xc000017170, {0x7295fa0?, 0xc0021d2008?})
github.com/hashicorp/terraform-provider-azurerm/internal/services/containers/kubernetes_cluster_data_source.go:789 +0x103e
test ran: https://dev.azure.com/akstelescope/telescope/_build/results?buildId=55817&view=results