forked from jcorioland/terraform-azure-ref-aks-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
69 lines (56 loc) · 1.65 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
59
60
61
62
63
64
65
66
67
68
69
provider "azuread" {
version = "~> 0.4"
}
provider "azurerm" {
version = "~> 1.31"
}
data "azurerm_resource_group" "rg" {
name = "tf-ref-${var.environment}-rg"
}
data "azurerm_subnet" "aks" {
name = "aks-subnet"
virtual_network_name = "aks-vnet"
resource_group_name = "${data.azurerm_resource_group.rg.name}"
}
resource "azurerm_kubernetes_cluster" "aks" {
name = "tf-ref-${var.environment}-aks"
location = "${data.azurerm_resource_group.rg.location}"
resource_group_name = "${data.azurerm_resource_group.rg.name}"
dns_prefix = "tf-ref-${var.environment}-aks"
kubernetes_version = "${var.kubernetes_version}"
linux_profile {
admin_username = "azureuser"
ssh_key {
key_data = "${var.ssh_public_key}"
}
}
agent_pool_profile {
name = "agentpool1"
count = "2"
vm_size = "Standard_DS2_v2"
os_type = "Linux"
os_disk_size_gb = 30
vnet_subnet_id = "${data.azurerm_subnet.aks.id}"
}
service_principal {
client_id = "${var.service_principal_client_id}"
client_secret = "${var.service_principal_client_secret}"
}
network_profile {
network_plugin = "kubenet"
}
role_based_access_control {
enabled = true
}
tags = {
Environment = "${var.environment}"
}
}
data "azuread_service_principal" "aks" {
application_id = "${var.service_principal_client_id}"
}
resource "azurerm_role_assignment" "netcontribrole" {
scope = "${data.azurerm_subnet.aks.id}"
role_definition_name = "Network Contributor"
principal_id = "${data.azuread_service_principal.aks.object_id}"
}