-
Notifications
You must be signed in to change notification settings - Fork 513
Expand file tree
/
Copy pathmain.tf
More file actions
90 lines (79 loc) · 2.93 KB
/
main.tf
File metadata and controls
90 lines (79 loc) · 2.93 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
resource "random_id" "prefix" {
byte_length = 8
}
resource "azurerm_resource_group" "main" {
count = var.create_resource_group ? 1 : 0
location = var.location
name = coalesce(var.resource_group_name, "${random_id.prefix.hex}-rg")
}
locals {
resource_group = {
name = var.create_resource_group ? azurerm_resource_group.main[0].name : var.resource_group_name
location = var.location
}
}
resource "azurerm_virtual_network" "test" {
address_space = ["10.52.0.0/16"]
location = local.resource_group.location
name = "${random_id.prefix.hex}-vn"
resource_group_name = local.resource_group.name
}
resource "azurerm_subnet" "test" {
address_prefixes = ["10.52.0.0/24"]
name = "${random_id.prefix.hex}-sn"
resource_group_name = local.resource_group.name
virtual_network_name = azurerm_virtual_network.test.name
enforce_private_link_endpoint_network_policies = true
}
resource "azurerm_user_assigned_identity" "test" {
location = local.resource_group.location
name = "${random_id.prefix.hex}-identity"
resource_group_name = local.resource_group.name
}
# Just for demo purpose, not necessary to named cluster.
resource "azurerm_log_analytics_workspace" "main" {
location = local.resource_group.location
name = "prefix-workspace"
resource_group_name = local.resource_group.name
retention_in_days = 30
sku = "PerGB2018"
}
module "aks_cluster_name" {
source = "../.."
prefix = "prefix"
resource_group_name = local.resource_group.name
admin_username = null
azure_policy_enabled = true
cluster_log_analytics_workspace_name = "test-cluster"
cluster_name = "test-cluster"
disk_encryption_set_id = azurerm_disk_encryption_set.des.id
identity_ids = [azurerm_user_assigned_identity.test.id]
identity_type = "UserAssigned"
log_analytics_workspace_enabled = true
log_analytics_workspace = {
id = azurerm_log_analytics_workspace.main.id
name = azurerm_log_analytics_workspace.main.name
}
maintenance_window = {
allowed = [
{
day = "Sunday",
hours = [22, 23]
},
]
not_allowed = []
}
net_profile_pod_cidr = "10.1.0.0/16"
private_cluster_enabled = true
rbac_aad = true
rbac_aad_managed = true
role_based_access_control_enabled = true
# KMS etcd encryption
kms_enabled = true
kms_key_vault_key_id = azurerm_key_vault_key.kms.id
kms_key_vault_network_access = "Private"
depends_on = [
azurerm_key_vault_access_policy.kms,
azurerm_role_assignment.kms
]
}