I am deploying my infra with terraform, but for AKS I use ARM templating because it has some features that are not in TF yet. So in my tf template I have the following resource defined to deploy an ARM template:
resource "azurerm_template_deployment" "k8s" {
name = "${var.environment}-aks-deployment"
resource_group_name = "${azurerm_resource_group.kubernetes.name}"
parameters = {
workspaceResourceId = "${azurerm_log_analytics_workspace.k8s-law.id}"
aksClusterName = "fntm-k8s-${var.environment}"
subnetKubernetes = "${azurerm_subnet.kubernetes.id}"
servicePrincipal = "${azuread_service_principal.k8s_sp.application_id}"
clientSecret = "${random_string.sp_password.result}"
clientAppID = "${var.clientAppID}"
serverAppID = "${var.serverAppID}"
tenantID = "${var.tenant_id}"
serverAppSecret = "${var.serverAppSecret}"
}
template_body = "${file("kubernetes/azuredeploy.json")}"
deployment_mode = "Incremental"
}
The deployment of the cluster goes fine, but after that I need to get data from the AKS cluster which will be used by a different module. If I use the data resource for AKS it tries to get the cluster data before it is deployed. So the below part doesn't work.
data "azurerm_kubernetes_cluster" "kubernetes" {
name = "fntm-k8s-${var.environment}"
resource_group_name = "${azurerm_resource_group.kubernetes.name}"
}
I thought maybe a depends_on but that is not supported in the data resource.
Anybody maybe an idea how I can get the data attribute node_resource_group from the AKS cluster with output? Or any other thoughts/solutions?
output "k8s_resource_group" {
value = "${lookup(azurerm_template_deployment.k8s.outputs, "?????")}"
}
azuredeploy.json
file? – ydaetskcoR