Skip to content

Commit 3770c0b

Browse files
committed
Changes
1 parent af4a2cb commit 3770c0b

4 files changed

Lines changed: 23 additions & 30 deletions

File tree

quickstart/201-k8s-cluster-with-aks-applicationgateway-ingress/main.tf

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
# Randomized resource group name to ensure uniqueness in your environment
2-
resource "random_pet" "rg-name" {
3-
prefix = var.name_prefix
4-
}
5-
6-
resource "azurerm_resource_group" "default" {
7-
name = random_pet.rg-name.id
8-
location = var.location
9-
}
10-
111
# Locals block for hardcoded names
122
locals {
133
backend_address_pool_name = "${azurerm_virtual_network.test.name}-beap"
@@ -20,13 +10,13 @@ locals {
2010
}
2111

2212
data "azurerm_resource_group" "rg" {
23-
name = azurerm_resource_group.default.name
13+
name = var.resource_group_name
2414
}
2515

2616
# User Assigned Identities
2717
resource "azurerm_user_assigned_identity" "testIdentity" {
28-
resource_group_name = azurerm_resource_group.default.name
29-
location = azurerm_resource_group.default.location
18+
resource_group_name = data.azurerm_resource_group.rg.name
19+
location = data.azurerm_resource_group.rg.location
3020

3121
name = "identity1"
3222

@@ -35,8 +25,8 @@ resource "azurerm_user_assigned_identity" "testIdentity" {
3525

3626
resource "azurerm_virtual_network" "test" {
3727
name = var.virtual_network_name
38-
location = azurerm_resource_group.default.location
39-
resource_group_name = azurerm_resource_group.default.name
28+
location = data.azurerm_resource_group.rg.location
29+
resource_group_name = data.azurerm_resource_group.rg.name
4030
address_space = [var.virtual_network_address_prefix]
4131

4232
subnet {
@@ -55,22 +45,22 @@ resource "azurerm_virtual_network" "test" {
5545
data "azurerm_subnet" "kubesubnet" {
5646
name = var.aks_subnet_name
5747
virtual_network_name = azurerm_virtual_network.test.name
58-
resource_group_name = azurerm_resource_group.default.name
48+
resource_group_name = data.azurerm_resource_group.rg.name
5949
depends_on = [azurerm_virtual_network.test]
6050
}
6151

6252
data "azurerm_subnet" "appgwsubnet" {
6353
name = "appgwsubnet"
6454
virtual_network_name = azurerm_virtual_network.test.name
65-
resource_group_name = azurerm_resource_group.default.name
55+
resource_group_name = data.azurerm_resource_group.rg.name
6656
depends_on = [azurerm_virtual_network.test]
6757
}
6858

6959
# Public Ip
7060
resource "azurerm_public_ip" "test" {
7161
name = "publicIp1"
72-
location = azurerm_resource_group.default.location
73-
resource_group_name = azurerm_resource_group.default.name
62+
location = data.azurerm_resource_group.rg.location
63+
resource_group_name = data.azurerm_resource_group.rg.name
7464
allocation_method = "Static"
7565
sku = "Standard"
7666

@@ -79,8 +69,8 @@ resource "azurerm_public_ip" "test" {
7969

8070
resource "azurerm_application_gateway" "network" {
8171
name = var.app_gateway_name
82-
resource_group_name = azurerm_resource_group.default.name
83-
location = azurerm_resource_group.default.location
72+
resource_group_name = data.azurerm_resource_group.rg.name
73+
location = data.azurerm_resource_group.rg.location
8474

8575
sku {
8676
name = var.app_gateway_sku
@@ -163,18 +153,18 @@ resource "azurerm_role_assignment" "ra3" {
163153
}
164154

165155
resource "azurerm_role_assignment" "ra4" {
166-
scope = azurerm_resource_group.default.id
156+
scope = data.azurerm_resource_group.rg.id
167157
role_definition_name = "Reader"
168158
principal_id = azurerm_user_assigned_identity.testIdentity.principal_id
169159
depends_on = [azurerm_user_assigned_identity.testIdentity, azurerm_application_gateway.network]
170160
}
171161

172162
resource "azurerm_kubernetes_cluster" "k8s" {
173163
name = var.aks_name
174-
location = azurerm_resource_group.default.location
164+
location = data.azurerm_resource_group.rg.location
175165
dns_prefix = var.aks_dns_prefix
176166

177-
resource_group_name = azurerm_resource_group.default.name
167+
resource_group_name = data.azurerm_resource_group.rg.name
178168

179169
linux_profile {
180170
admin_username = var.vm_user_name

quickstart/201-k8s-cluster-with-aks-applicationgateway-ingress/output.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
output "resource_group_name" {
2-
value = azurerm_resource_group.default.name
3-
}
4-
51
output "client_key" {
62
value = azurerm_kubernetes_cluster.k8s.kube_config.0.client_key
73
}

quickstart/201-k8s-cluster-with-aks-applicationgateway-ingress/terraform.tfvars

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
resource_group_name = "<Resource group name>"
2+
3+
location = "<Resource group location>"
4+
15
aks_service_principal_app_id = "<Service principal appId>"
26

37
aks_service_principal_client_secret = "<Service principal password>"

quickstart/201-k8s-cluster-with-aks-applicationgateway-ingress/variables.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
variable "resource_group_name" {
2+
description = "Name of the resource group."
3+
}
4+
15
variable "location" {
2-
default = "eastus"
3-
description = "Location of the cluster"
6+
description = "Location of the cluster."
47
}
58

69
variable "aks_service_principal_app_id" {

0 commit comments

Comments
 (0)