1-
21module "network" {
3- source = " Azure/network/azurerm"
2+ source = " Azure/subnets/azurerm"
3+ version = " 1.0.0"
4+
45 resource_group_name = azurerm_resource_group. example . name
5- address_space = " 10.52.0.0/16"
6- subnet_prefixes = [" 10.52.0.0/24" ]
7- subnet_names = [" subnet1" ]
8- depends_on = [azurerm_resource_group . example ]
9- subnet_enforce_private_link_endpoint_network_policies = {
10- " subnet1" : true
6+ subnets = {
7+ subnet1 = {
8+ address_prefixes = [" 10.52.0.0/24" ]
9+ private_endpoint_network_policies_enabled = true
10+ }
1111 }
12+ virtual_network_address_space = [" 10.52.0.0/16" ]
13+ virtual_network_location = azurerm_resource_group. example . location
14+ virtual_network_name = " subnet1"
1215}
1316
1417resource "azurerm_container_registry" "example" {
@@ -26,44 +29,35 @@ resource "azurerm_role_assignment" "example" {
2629 depends_on = [module . aks ]
2730}
2831
29- # Grant AKS cluster access to use AKS subnet
30- resource "azurerm_role_assignment" "aks" {
31- principal_id = module. aks . system_assigned_identity [0 ]. principal_id
32- role_definition_name = " Network Contributor"
33- scope = module. network . vnet_subnets [0 ]
34- depends_on = [module . aks ]
35- }
36-
3732module "aks" {
38- source = " Azure/aks/azurerm"
39- version = " 4.16.0"
40- resource_group_name = azurerm_resource_group. example . name
41- client_id = var. client_id
42- client_secret = var. client_secret
43- kubernetes_version = " 1.23.5"
44- orchestrator_version = " 1.23.5"
45- prefix = " default"
46- cluster_name = var. cluster_name
47- network_plugin = " azure"
48- vnet_subnet_id = module. network . vnet_subnets [0 ]
49- os_disk_size_gb = 50
50- sku_tier = " Paid" # defaults to Free
51- enable_role_based_access_control = true
52- rbac_aad_admin_group_object_ids = var. rbac_aad_admin_group_object_ids
53- rbac_aad_managed = true
54- private_cluster_enabled = false
55- enable_http_application_routing = true
56- enable_azure_policy = true
57- enable_auto_scaling = true
58- enable_host_encryption = false
59- agents_min_count = 1
60- agents_max_count = 1
61- agents_count = null # Please set `agents_count` `null` while `enable_auto_scaling` is `true` to avoid possible `agents_count` changes.
62- agents_max_pods = 100
63- agents_pool_name = " exnodepool"
64- agents_availability_zones = [" 1" , " 2" ]
65- agents_type = " VirtualMachineScaleSets"
66- agents_size = " standard_dc2s_v2"
33+ source = " Azure/aks/azurerm"
34+ version = " 8.0.0"
35+ resource_group_name = azurerm_resource_group. example . name
36+ client_id = var. client_id
37+ client_secret = var. client_secret
38+ kubernetes_version = " 1.29.2"
39+ orchestrator_version = " 1.29.2"
40+ prefix = " default"
41+ cluster_name = var. cluster_name
42+ network_plugin = " azure"
43+ vnet_subnet_id = module. network . vnet_subnets_name_id [" subnet1" ]
44+ os_disk_size_gb = 50
45+ sku_tier = " Standard"
46+ role_based_access_control_enabled = true
47+ rbac_aad_admin_group_object_ids = var. rbac_aad_admin_group_object_ids
48+ rbac_aad_managed = true
49+ private_cluster_enabled = false
50+ web_app_routing = { dns_zone_id = " " }
51+ enable_auto_scaling = true
52+ enable_host_encryption = false
53+ agents_min_count = 1
54+ agents_max_count = 1
55+ agents_count = null # Please set `agents_count` `null` while `enable_auto_scaling` is `true` to avoid possible `agents_count` changes.
56+ agents_max_pods = 100
57+ agents_pool_name = " exnodepool"
58+ agents_availability_zones = [" 1" , " 2" ]
59+ agents_type = " VirtualMachineScaleSets"
60+ agents_size = " standard_dc2s_v2"
6761
6862 agents_labels = {
6963 " nodepool" : " defaultnodepool"
@@ -73,14 +67,12 @@ module "aks" {
7367 " Agent" : " defaultnodepoolagent"
7468 }
7569
76- enable_ingress_application_gateway = true
77- ingress_application_gateway_name = " aks-agw "
78- ingress_application_gateway_subnet_cidr = " 10.52.1 .0/24 "
70+ network_policy = " azure "
71+ net_profile_dns_service_ip = " 10.0.0.10 "
72+ net_profile_service_cidr = " 10.0.0 .0/16 "
7973
80- network_policy = " azure"
81- net_profile_dns_service_ip = " 10.0.0.10"
82- net_profile_docker_bridge_cidr = " 172.16.0.1/16"
83- net_profile_service_cidr = " 10.0.0.0/16"
74+ # Grant AKS cluster access to use AKS subnet
75+ network_contributor_role_assigned_subnet_ids = { " subnet1" = module.network.vnet_subnets_name_id[" subnet1" ] }
8476
8577 depends_on = [module . network ]
8678}
0 commit comments