forked from Azure/terraform-azurerm-aks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
76 lines (61 loc) · 2.16 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
70
71
72
73
74
data "azurerm_resource_group" "main" {
name = var.resource_group_name
}
module "ssh-key" {
source = "./modules/ssh-key"
public_ssh_key = var.public_ssh_key == "" ? "" : var.public_ssh_key
}
resource "azurerm_kubernetes_cluster" "main" {
name = "${var.prefix}-aks"
location = data.azurerm_resource_group.main.location
resource_group_name = data.azurerm_resource_group.main.name
dns_prefix = var.prefix
linux_profile {
admin_username = var.admin_username
ssh_key {
# remove any new lines using the replace interpolation function
key_data = replace(var.public_ssh_key == "" ? module.ssh-key.public_ssh_key : var.public_ssh_key, "\n", "")
}
}
default_node_pool {
name = "nodepool"
node_count = var.agents_count
vm_size = var.agents_size
os_disk_size_gb = 50
}
service_principal {
client_id = var.client_id
client_secret = var.client_secret
}
dynamic addon_profile {
for_each = var.enable_log_analytics_workspace ? ["log_analytics"] : []
content {
oms_agent {
enabled = true
log_analytics_workspace_id = azurerm_log_analytics_workspace.main[0].id
}
}
}
tags = var.tags
}
resource "azurerm_log_analytics_workspace" "main" {
count = var.enable_log_analytics_workspace ? 1 : 0
name = "${var.prefix}-workspace"
location = data.azurerm_resource_group.main.location
resource_group_name = var.resource_group_name
sku = var.log_analytics_workspace_sku
retention_in_days = var.log_retention_in_days
tags = var.tags
}
resource "azurerm_log_analytics_solution" "main" {
count = var.enable_log_analytics_workspace ? 1 : 0
solution_name = "ContainerInsights"
location = data.azurerm_resource_group.main.location
resource_group_name = var.resource_group_name
workspace_resource_id = azurerm_log_analytics_workspace.main[0].id
workspace_name = azurerm_log_analytics_workspace.main[0].name
plan {
publisher = "Microsoft"
product = "OMSGallery/ContainerInsights"
}
}