Randomizing resource group and leaving in tfvars only the min the cust needs to mod
This commit is contained in:
parent
c25d0c2f2f
commit
af4a2cbdd5
@ -1,4 +1,14 @@
|
||||
# # Locals block for hardcoded names.
|
||||
# Randomized resource group name to ensure uniqueness in your environment
|
||||
resource "random_pet" "rg-name" {
|
||||
prefix = var.name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "default" {
|
||||
name = random_pet.rg-name.id
|
||||
location = var.location
|
||||
}
|
||||
|
||||
# Locals block for hardcoded names
|
||||
locals {
|
||||
backend_address_pool_name = "${azurerm_virtual_network.test.name}-beap"
|
||||
frontend_port_name = "${azurerm_virtual_network.test.name}-feport"
|
||||
@ -10,13 +20,13 @@ locals {
|
||||
}
|
||||
|
||||
data "azurerm_resource_group" "rg" {
|
||||
name = var.resource_group_name
|
||||
name = azurerm_resource_group.default.name
|
||||
}
|
||||
|
||||
# User Assigned Identities
|
||||
resource "azurerm_user_assigned_identity" "testIdentity" {
|
||||
resource_group_name = data.azurerm_resource_group.rg.name
|
||||
location = data.azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
location = azurerm_resource_group.default.location
|
||||
|
||||
name = "identity1"
|
||||
|
||||
@ -25,8 +35,8 @@ resource "azurerm_user_assigned_identity" "testIdentity" {
|
||||
|
||||
resource "azurerm_virtual_network" "test" {
|
||||
name = var.virtual_network_name
|
||||
location = data.azurerm_resource_group.rg.location
|
||||
resource_group_name = data.azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
address_space = [var.virtual_network_address_prefix]
|
||||
|
||||
subnet {
|
||||
@ -45,22 +55,22 @@ resource "azurerm_virtual_network" "test" {
|
||||
data "azurerm_subnet" "kubesubnet" {
|
||||
name = var.aks_subnet_name
|
||||
virtual_network_name = azurerm_virtual_network.test.name
|
||||
resource_group_name = data.azurerm_resource_group.rg.name
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
depends_on = [azurerm_virtual_network.test]
|
||||
}
|
||||
|
||||
data "azurerm_subnet" "appgwsubnet" {
|
||||
name = "appgwsubnet"
|
||||
virtual_network_name = azurerm_virtual_network.test.name
|
||||
resource_group_name = data.azurerm_resource_group.rg.name
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
depends_on = [azurerm_virtual_network.test]
|
||||
}
|
||||
|
||||
# Public Ip
|
||||
resource "azurerm_public_ip" "test" {
|
||||
name = "publicIp1"
|
||||
location = data.azurerm_resource_group.rg.location
|
||||
resource_group_name = data.azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
allocation_method = "Static"
|
||||
sku = "Standard"
|
||||
|
||||
@ -69,8 +79,8 @@ resource "azurerm_public_ip" "test" {
|
||||
|
||||
resource "azurerm_application_gateway" "network" {
|
||||
name = var.app_gateway_name
|
||||
resource_group_name = data.azurerm_resource_group.rg.name
|
||||
location = data.azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
location = azurerm_resource_group.default.location
|
||||
|
||||
sku {
|
||||
name = var.app_gateway_sku
|
||||
@ -153,7 +163,7 @@ resource "azurerm_role_assignment" "ra3" {
|
||||
}
|
||||
|
||||
resource "azurerm_role_assignment" "ra4" {
|
||||
scope = data.azurerm_resource_group.rg.id
|
||||
scope = azurerm_resource_group.default.id
|
||||
role_definition_name = "Reader"
|
||||
principal_id = azurerm_user_assigned_identity.testIdentity.principal_id
|
||||
depends_on = [azurerm_user_assigned_identity.testIdentity, azurerm_application_gateway.network]
|
||||
@ -161,10 +171,10 @@ resource "azurerm_role_assignment" "ra4" {
|
||||
|
||||
resource "azurerm_kubernetes_cluster" "k8s" {
|
||||
name = var.aks_name
|
||||
location = data.azurerm_resource_group.rg.location
|
||||
location = azurerm_resource_group.default.location
|
||||
dns_prefix = var.aks_dns_prefix
|
||||
|
||||
resource_group_name = data.azurerm_resource_group.rg.name
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
|
||||
linux_profile {
|
||||
admin_username = var.vm_user_name
|
||||
|
@ -1,3 +1,7 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.default.name
|
||||
}
|
||||
|
||||
output "client_key" {
|
||||
value = azurerm_kubernetes_cluster.k8s.kube_config.0.client_key
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
resource_group_name = "<Name of the Resource Group already created>"
|
||||
|
||||
location = "<Location of the Resource Group>"
|
||||
aks_service_principal_app_id = "<Service principal appId>"
|
||||
|
||||
aks_service_principal_app_id = "<Service Principal AppId>"
|
||||
aks_service_principal_client_secret = "<Service principal password>"
|
||||
|
||||
aks_service_principal_client_secret = "<Service Principal Client Secret>"
|
||||
|
||||
aks_service_principal_object_id = "<Service Principal Object Id>"
|
||||
aks_service_principal_object_id = "<Service principal object ID>"
|
||||
|
@ -1,9 +1,6 @@
|
||||
variable "resource_group_name" {
|
||||
description = "Name of the resource group."
|
||||
}
|
||||
|
||||
variable "location" {
|
||||
description = "Location of the cluster."
|
||||
default = "eastus"
|
||||
description = "Location of the cluster"
|
||||
}
|
||||
|
||||
variable "aks_service_principal_app_id" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user