Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#24358: Support vm_template for azurerm_virtual_desktop_host_pool resource #24369

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ func resourceVirtualDesktopHostPool() *pluginsdk.Resource {
},
},

"vm_template": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsJSON,
DiffSuppressFunc: pluginsdk.SuppressJsonDiff,
},

"tags": commonschema.Tags(),
},
}
Expand All @@ -220,6 +227,15 @@ func resourceVirtualDesktopHostPoolCreate(d *pluginsdk.ResourceData, meta interf
}

personalDesktopAssignmentType := hostpool.PersonalDesktopAssignmentType(d.Get("personal_desktop_assignment_type").(string))
vmTemplate := utils.String(d.Get("vm_template").(string))
if *vmTemplate != "" {
// we have no use with the json object as azure accepts string only
// merely here for validation
_, err := pluginsdk.ExpandJsonFromString(*vmTemplate)
harshavmb marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return fmt.Errorf("expanding JSON for `vm_template`: %+v", err)
}
}
payload := hostpool.HostPool{
Location: utils.String(location.Normalize(d.Get("location").(string))),
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
Expand All @@ -235,6 +251,7 @@ func resourceVirtualDesktopHostPoolCreate(d *pluginsdk.ResourceData, meta interf
PersonalDesktopAssignmentType: &personalDesktopAssignmentType,
PreferredAppGroupType: hostpool.PreferredAppGroupType(d.Get("preferred_app_group_type").(string)),
AgentUpdate: expandAgentUpdateCreate(d.Get("scheduled_agent_updates").([]interface{})),
VMTemplate: vmTemplate,
},
}

Expand Down Expand Up @@ -305,6 +322,10 @@ func resourceVirtualDesktopHostPoolUpdate(d *pluginsdk.ResourceData, meta interf
if d.HasChanges("scheduled_agent_updates") {
payload.Properties.AgentUpdate = expandAgentUpdatePatch(d.Get("scheduled_agent_updates").([]interface{}))
}

if d.HasChanges("vm_template") {
payload.Properties.VMTemplate = utils.String(d.Get("vm_template").(string))
}
}

if _, err := client.Update(ctx, *id, payload); err != nil {
Expand Down Expand Up @@ -365,6 +386,7 @@ func resourceVirtualDesktopHostPoolRead(d *pluginsdk.ResourceData, meta interfac
d.Set("type", string(props.HostPoolType))
d.Set("validate_environment", props.ValidationEnvironment)
d.Set("scheduled_agent_updates", flattenAgentUpdate(props.AgentUpdate))
d.Set("vm_template", props.VMTemplate)
}

return nil
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/virtual_desktop_host_pool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ The following arguments are supported:

* `scheduled_agent_updates` - (Optional) A `scheduled_agent_updates` block as defined below. This enables control of when Agent Updates will be applied to Session Hosts.

* `vm_template` - (Optional) A VM template for sessionhosts configuration within hostpool. This is a JSON string.
harshavmb marked this conversation as resolved.
Show resolved Hide resolved

* `tags` - (Optional) A mapping of tags to assign to the resource.

---
Expand Down