forked from Azure/terraform-azurerm-aks
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.tf
More file actions
55 lines (47 loc) · 1.61 KB
/
main.tf
File metadata and controls
55 lines (47 loc) · 1.61 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
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
}
locals {
nodes = {
for i in range(3) : "worker${i}" => {
name = substr("worker${i}${random_id.prefix.hex}", 0, 12)
vm_size = "Standard_D2s_v3"
node_count = 1
vnet_subnet_id = azurerm_subnet.test.id
}
}
}
module "aks" {
source = "../.."
prefix = "prefix-${random_id.prefix.hex}"
resource_group_name = local.resource_group.name
os_disk_size_gb = 60
sku_tier = "Standard"
rbac_aad = false
vnet_subnet_id = azurerm_subnet.test.id
node_pools = local.nodes
}