Azurerm Data Provider for aks cluster errors out before using the timeout settings

Trying to get cluster data with data “azurerm_kubernetes_cluster” data provider and it gives and error automatically that cannot find the cluster. I’m trying to use the kubernetes and helm provider to deploy helm packages. I tried the timeout setting and set it to 20 minutes for read of the data and it does not seem to work. Any advice would be appreciated.

data "azurerm_kubernetes_cluster" "aks_cluster" {
name                = var.kube_cluster_name
resource_group_name = var.kube_resource_group_name
timeouts {
read = "20m"

Error: Error: Managed Kubernetes Cluster “staging” was not found in Resource Group “staging”

I’m trying to deploy the cluster and helm packages in one stage.

Hi @terraform-class,

here you’re filtering on pre-defined variables. As those are known and don’t have a dependency on another resource attribute (like azurerm_…) terraform executes the query ASAP and might fail.
So you have to add a resource reference within the data source.