Skip to content

Commit 1ad1fd2

Browse files
committed
Refresh Terraform code to April 2024 provider and modules versions
1 parent 34940be commit 1ad1fd2

File tree

4 files changed

+64
-68
lines changed

4 files changed

+64
-68
lines changed

039-AKSEnterpriseGrade/Coach/Solutions/Challenge-02/Terraform/database.tf

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
resource "azurerm_mysql_server" "example" {
1+
resource "azurerm_mysql_flexible_server" "example" {
22
name = random_string.random.result
33
#location = azurerm_resource_group.example.location
44
location = "eastus"
55
resource_group_name = azurerm_resource_group.example.name
66

7-
administrator_login = "mysqlazureadmin"
8-
administrator_login_password = var.databasepassword
7+
administrator_login = "mysqlazureadmin"
8+
administrator_password = var.databasepassword
99

10-
sku_name = "GP_Gen5_2"
11-
storage_mb = 5120
12-
version = "5.7"
10+
sku_name = "GP_Standard_D2ds_v4"
1311

14-
auto_grow_enabled = true
15-
backup_retention_days = 7
16-
geo_redundant_backup_enabled = false
17-
infrastructure_encryption_enabled = false
18-
public_network_access_enabled = false
19-
ssl_enforcement_enabled = false
12+
backup_retention_days = 7
13+
geo_redundant_backup_enabled = false
2014
}
2115

2216
resource "azurerm_private_endpoint" "example" {
2317
name = "${random_string.random.result}-endpoint"
2418
location = "westeurope"
2519
resource_group_name = azurerm_resource_group.example.name
26-
subnet_id = module.network.vnet_subnets[0]
20+
subnet_id = module.network.vnet_subnets_name_id["subnet1"]
2721

2822
private_service_connection {
2923
name = "${random_string.random.result}-privateserviceconnection"
30-
private_connection_resource_id = azurerm_mysql_server.example.id
24+
private_connection_resource_id = azurerm_mysql_flexible_server.example.id
3125
subresource_names = ["mysqlServer"]
3226
is_manual_connection = false
3327
}

039-AKSEnterpriseGrade/Coach/Solutions/Challenge-02/Terraform/main.tf

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
21
module "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+
service_endpoints = ["Microsoft.Storage"]
11+
delegations = [
12+
{
13+
name = "Microsoft.DBforMySQL.flexibleServers"
14+
service_delegation = {
15+
name = "Microsoft.DBforMySQL/flexibleServers"
16+
actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
17+
}
18+
}
19+
]
20+
}
1121
}
22+
virtual_network_address_space = ["10.52.0.0/16"]
23+
virtual_network_location = azurerm_resource_group.example.location
24+
virtual_network_name = "subnet1"
1225
}
1326

1427
resource "azurerm_container_registry" "example" {
@@ -26,44 +39,35 @@ resource "azurerm_role_assignment" "example" {
2639
depends_on = [module.aks]
2740
}
2841

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-
3742
module "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"
43+
source = "Azure/aks/azurerm"
44+
version = "8.0.0"
45+
resource_group_name = azurerm_resource_group.example.name
46+
client_id = var.client_id
47+
client_secret = var.client_secret
48+
kubernetes_version = "1.29.2"
49+
orchestrator_version = "1.29.2"
50+
prefix = "default"
51+
cluster_name = var.cluster_name
52+
network_plugin = "azure"
53+
vnet_subnet_id = module.network.vnet_subnets_name_id["subnet1"]
54+
os_disk_size_gb = 50
55+
sku_tier = "Standard"
56+
role_based_access_control_enabled = true
57+
rbac_aad_admin_group_object_ids = var.rbac_aad_admin_group_object_ids
58+
rbac_aad_managed = true
59+
private_cluster_enabled = false
60+
web_app_routing = { dns_zone_id = "" }
61+
enable_auto_scaling = true
62+
enable_host_encryption = false
63+
agents_min_count = 1
64+
agents_max_count = 1
65+
agents_count = null # Please set `agents_count` `null` while `enable_auto_scaling` is `true` to avoid possible `agents_count` changes.
66+
agents_max_pods = 100
67+
agents_pool_name = "exnodepool"
68+
agents_availability_zones = ["1", "2"]
69+
agents_type = "VirtualMachineScaleSets"
70+
agents_size = "standard_dc2s_v2"
6771

6872
agents_labels = {
6973
"nodepool" : "defaultnodepool"
@@ -73,14 +77,12 @@ module "aks" {
7377
"Agent" : "defaultnodepoolagent"
7478
}
7579

76-
enable_ingress_application_gateway = true
77-
ingress_application_gateway_name = "aks-agw"
78-
ingress_application_gateway_subnet_cidr = "10.52.1.0/24"
80+
network_policy = "azure"
81+
net_profile_dns_service_ip = "10.0.0.10"
82+
net_profile_service_cidr = "10.0.0.0/16"
7983

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"
84+
# Grant AKS cluster access to use AKS subnet
85+
network_contributor_role_assigned_subnet_ids = { "subnet1" = module.network.vnet_subnets_name_id["subnet1"] }
8486

8587
depends_on = [module.network]
8688
}

039-AKSEnterpriseGrade/Coach/Solutions/Challenge-02/Terraform/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
azurerm = {
44
source = "hashicorp/azurerm"
5-
version = "~> 2.46"
5+
version = ">= 3.99"
66
}
77
}
88

039-AKSEnterpriseGrade/Coach/Solutions/Challenge-02/Terraform/tfvars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
agents_size = "standard_dc2s_v2"
1+
agents_size = "Standard_D2d_v5"
22
rbac_aad_admin_group_object_ids = [""]
33
resource_group_name = ""
44
identity_type = "SystemAssigned"

0 commit comments

Comments
 (0)