refactor code
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
# Create AVD Resource Group
|
||||
# Randomization of resource group name.
|
||||
# Resource group name is output when execution plan is applied.
|
||||
resource "random_pet" "rg-name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
name = var.rg_name
|
||||
location = var.deploy_location
|
||||
name = random_pet.rg-name.id
|
||||
location = var.resource_group_location
|
||||
}
|
||||
|
||||
# Create AVD workspace
|
||||
@ -13,10 +17,6 @@ resource "azurerm_virtual_desktop_workspace" "workspace" {
|
||||
description = "${var.prefix} Workspace"
|
||||
}
|
||||
|
||||
resource "time_rotating" "avd_token" {
|
||||
rotation_days = 30
|
||||
}
|
||||
|
||||
# Create AVD host pool
|
||||
resource "azurerm_virtual_desktop_host_pool" "hostpool" {
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
@ -30,9 +30,14 @@ resource "azurerm_virtual_desktop_host_pool" "hostpool" {
|
||||
maximum_sessions_allowed = 16
|
||||
load_balancer_type = "DepthFirst" #[BreadthFirst DepthFirst]
|
||||
|
||||
registration_info {
|
||||
expiration_date = time_rotating.avd_token.rotation_rfc3339
|
||||
}
|
||||
|
||||
# Create registration info
|
||||
resource "time_rotating" "avd_token" {
|
||||
rotation_days = 30
|
||||
}
|
||||
resource "azurerm_virtual_desktop_host_pool_registration_info" "registrationinfo" {
|
||||
hostpool_id = azurerm_virtual_desktop_host_pool.hostpool.id
|
||||
expiration_date = time_rotating.avd_token.rfc3339
|
||||
}
|
||||
|
||||
# Create AVD DAG
|
||||
|
@ -3,6 +3,14 @@ output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "azurerm_virtual_desktop_application_group" {
|
||||
value = azurerm_virtual_desktop_application_group.dag.name
|
||||
}
|
||||
|
||||
output "azurerm_virtual_desktop_workspace" {
|
||||
value = azurerm_virtual_desktop_workspace.workspace.name
|
||||
}
|
||||
|
||||
output "location" {
|
||||
description = "The Azure region"
|
||||
value = azurerm_resource_group.rg.location
|
||||
|
@ -1,3 +1,12 @@
|
||||
variable "resource_group_name_prefix" {
|
||||
default = "rg"
|
||||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||
}
|
||||
|
||||
variable "resource_group_location" {
|
||||
default = "eastus"
|
||||
description = "Location of the resource group."
|
||||
}
|
||||
variable "rg_name" {
|
||||
type = string
|
||||
default = "avd-resources-rg"
|
||||
@ -6,7 +15,7 @@ variable "rg_name" {
|
||||
|
||||
variable "deploy_location" {
|
||||
type = string
|
||||
default = "east us"
|
||||
default = "eastus"
|
||||
description = "The Azure Region in which all resources in this example should be created."
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user