Skip to content

Commit f84cf85

Browse files
committed
Add in additional permissions for the AVD to deploy
Have to add role assignment "Desktop Virtualization Power On Off Contributor" to allow AVD to deploy in the Lung project.
1 parent 25275d9 commit f84cf85

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

infrastructure/modules/virtual-desktop/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ resource "azurerm_virtual_desktop_workspace_application_group_association" "this
5858
workspace_id = azurerm_virtual_desktop_workspace.this.id
5959
}
6060

61+
resource "azurerm_role_assignment" "avd_autoscale_hostpool" {
62+
count = var.principal_id == null ? 0 : 1
63+
64+
scope = azurerm_virtual_desktop_host_pool.this.id
65+
role_definition_name = "Desktop Virtualization Power On Off Contributor"
66+
principal_id = var.principal_id
67+
}
68+
6169
resource "azurerm_role_assignment" "rg_users" {
6270
scope = var.resource_group_id
6371
role_definition_name = "Virtual Machine User Login"

infrastructure/modules/virtual-desktop/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,9 @@ variable "tags" {
187187
type = map(string)
188188
default = {}
189189
}
190+
191+
variable "principal_id" {
192+
description = "The principal (object) ID to assign the 'Desktop Virtualization Power On Off Contributor' role to the host pool. If null, the role assignment will not be created. This maintains backward compatibility for existing deployments. The role is required for autoscaling but can be omitted if autoscaling is not used or the role is assigned manually."
193+
type = string
194+
default = null
195+
}

0 commit comments

Comments
 (0)