-
Notifications
You must be signed in to change notification settings - Fork 986
/
main.tf
58 lines (51 loc) · 1.84 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.0.3"
}
azurerm = {
source = "hashicorp/azurerm"
version = "2.42"
}
helm = {
source = "hashicorp/helm"
version = ">= 2.1.0"
}
}
}
data "azurerm_kubernetes_cluster" "default" {
depends_on = [module.aks-cluster] # refresh cluster state before reading
name = local.cluster_name
resource_group_name = local.cluster_name
}
provider "kubernetes" {
host = data.azurerm_kubernetes_cluster.default.kube_config.0.host
client_certificate = base64decode(data.azurerm_kubernetes_cluster.default.kube_config.0.client_certificate)
client_key = base64decode(data.azurerm_kubernetes_cluster.default.kube_config.0.client_key)
cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.default.kube_config.0.cluster_ca_certificate)
}
provider "helm" {
kubernetes {
host = data.azurerm_kubernetes_cluster.default.kube_config.0.host
client_certificate = base64decode(data.azurerm_kubernetes_cluster.default.kube_config.0.client_certificate)
client_key = base64decode(data.azurerm_kubernetes_cluster.default.kube_config.0.client_key)
cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.default.kube_config.0.cluster_ca_certificate)
}
}
provider "azurerm" {
features {}
}
module "aks-cluster" {
source = "./aks-cluster"
cluster_name = local.cluster_name
location = var.location
}
module "kubernetes-config" {
depends_on = [module.aks-cluster]
source = "./kubernetes-config"
cluster_name = local.cluster_name
kubeconfig = data.azurerm_kubernetes_cluster.default.kube_config_raw
}