Tuesday, December 21, 2021

Azure kubernetes terraform - data source for getting latest Azure AKS versions

 

terraform data source for getting latest Azure AKS versions:
az aks get-versions --location centralus -o table

instead of command we use datasourse.
aks-versions-datasource.tf
data "azure_kubernetes_service_versions" "current"{
 location = azure_resource_group.aks_rg.location
 include_preview = false
}

resource-group.tf
resource "azure_resource_group" "aks_rg"{
 name = "${var.resource_group_name}-${var.environment}"
 location = var.location
}

outputs.tf
output "versions"{
 value = data.azure_kubernetes_service_versions.current.versions
}

output "latest_version"{
 value = data.azure_kubernetes_service_versions.current.latest_version
}

No comments:

Post a Comment