Skip to content

Commit f0b8f06

Browse files
authored
feat(workspace): add new resource desktop pool (#6515)
1 parent 7d13615 commit f0b8f06

File tree

5 files changed

+1702
-0
lines changed

5 files changed

+1702
-0
lines changed
+310
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
---
2+
subcategory: "Workspace"
3+
layout: "huaweicloud"
4+
page_title: "HuaweiCloud: huaweicloud_workspace_desktop_pool"
5+
description: |-
6+
Manages a Workspace desktop pool resource within HuaweiCloud.
7+
---
8+
9+
# huaweicloud_workspace_desktop_pool
10+
11+
Manages a Workspace desktop pool resource within HuaweiCloud.
12+
13+
-> Before creating Workspace desktop, ensure that the Workspace service has been registered.
14+
15+
## Example Usage
16+
17+
```hcl
18+
variable "desktop_pool_name" {}
19+
variable "product_id" {}
20+
variable "image_id" {}
21+
variable "vpc_id" {}
22+
variable "subnet_ids" {
23+
type = list(string)
24+
}
25+
variable "security_group_ids" {
26+
type = list(string)
27+
}
28+
variable "data_volume_sizes" {
29+
type = list(number)
30+
}
31+
variable "authorized_object_list" {
32+
type = list(object({
33+
object_id = string
34+
object_type = string
35+
object_name = string
36+
user_group = string
37+
}))
38+
}
39+
40+
resource "huaweicloud_workspace_desktop_pool" "test" {
41+
name = var.desktop_pool_name
42+
type = "DYNAMIC"
43+
size = 1
44+
product_id = var.product_id
45+
image_type = "gold"
46+
image_id = var.image_id
47+
vpc_id = var.vpc_id
48+
subnet_ids = var.subnet_ids
49+
disconnected_retention_period = 10
50+
51+
root_volume {
52+
type = "SAS"
53+
size = 80
54+
}
55+
56+
dynamic "security_groups" {
57+
for_each = var.security_group_ids
58+
59+
content {
60+
id = security_groups.value
61+
}
62+
}
63+
64+
dynamic "data_volumes" {
65+
for_each = var.data_volume_sizes
66+
67+
content {
68+
type = "SAS"
69+
size = data_volumes.value
70+
}
71+
}
72+
73+
dynamic "authorized_objects" {
74+
for_each = var.authorized_object_list
75+
76+
content {
77+
object_id = authorized_objects.value.object_id
78+
object_type = authorized_objects.value.object_type
79+
object_name = authorized_objects.value.object_name
80+
user_group = authorized_objects.value.user_group
81+
}
82+
}
83+
}
84+
```
85+
86+
## Argument Reference
87+
88+
The following arguments are supported:
89+
90+
* `region` - (Optional, String, ForceNew) Specifies the region in which to create the resource.
91+
If omitted, the provider-level region will be used. Changing this parameter will create a new resource.
92+
93+
* `name` - (Required, String) Specifies the name of the desktop pool.
94+
The name valid length is limited from `1` to `15`, only Chinese and English characters, digits and hyphens (-) are allowed.
95+
96+
* `type` - (Required, String, NonUpdatable) Specifies the type of the desktop pool.
97+
The valid values are as follows:
98+
+ **DYNAMIC**
99+
+ **STATIC**
100+
101+
* `size` - (Required, Int, NonUpdatable) Specifies the number of the desktops under the desktop pool.
102+
The valid value ranges from `1` to `100`.
103+
104+
-> This parameter will be affected by `autoscale_policy` parameter and will appear when `terraform plan` or
105+
`terraform apply`. If it is inconsistent with the script configuration, it can be ignored by `ignore_changes`
106+
in non-change scenarios.
107+
108+
* `product_id` - (Required, String, NonUpdatable) Specifies the specification ID of the desktop pool.
109+
110+
* `image_type` - (Required, String, NonUpdatable) Specifies the image type of the desktop pool.
111+
The valid values are as follows:
112+
+ **private**
113+
+ **gold**
114+
115+
* `image_id` - (Required, String, NonUpdatable) Specifies the image ID of the desktop pool.
116+
117+
* `root_volume` - (Required, List, NonUpdatable) Specifies the system volume configuration of the desktop pool.
118+
The [root_volume](#desktop_pool_volume) structure is documented below.
119+
120+
* `subnet_ids` - (Required, List, NonUpdatable) Specifies the list of the subnet IDs to which the desktop pool belongs.
121+
122+
* `vpc_id` - (Optional, String) Specifies the ID of the VPC to which the desktop pool belongs.
123+
124+
* `security_groups` - (Optional, List, NonUpdatable) Specifies the list of the security groups to which the
125+
desktop pool belongs.
126+
The [security_groups](#desktop_pool_security_groups) structure is documented below.
127+
128+
* `data_volumes` - (Optional, List, NonUpdatable) Specifies the list of the data volume configurations of
129+
the desktop pool.
130+
The [data_volumes](#desktop_pool_volume) structure is documented below.
131+
132+
* `authorized_objects` - (Optional, List, NonUpdatable) Specifies the list of the users or user groups
133+
to be authorized.
134+
The [authorized_objects](#desktop_pool_authorized_objects) structure is documented below.
135+
136+
* `availability_zone` - (Optional, String) Specifies the availability zone to which the desktop pool belongs.
137+
138+
* `disconnected_retention_period` - (Optional, Int) Specifies the desktops and users disconnection retention period
139+
under desktop pool, in minutes.
140+
The valid value ranges from `10` to `43,200`.
141+
This parameter is available and required only when the `type` is set to **DYNAMIC**.
142+
143+
* `enable_autoscale` - (Optional, Bool) Specifies whether to enable elastic scaling of the desktop pool.
144+
Defaults to **false**.
145+
146+
* `autoscale_policy` - (Optional, List) Specifies the automatic scaling policy of the desktop pool.
147+
The [autoscale_policy](#desktop_pool_autoscale_policy) structure is documented below.
148+
This parameter is available only when the `enable_autoscale` is set to **true**.
149+
150+
* `desktop_name_policy_id` - (Optional, String) Specifies the ID of the policy to generate the desktop name.
151+
152+
* `ou_name` - (Optional, String) Specifies the OU name corresponding to the AD server.
153+
This parameter is available only when the AD server is connected.
154+
155+
* `enterprise_project_id` - (Optional, String, NonUpdatable) Specifies the ID of the enterprise project to which
156+
the desktop pool belongs.
157+
This parameter is only valid for enterprise users, if omitted, default enterprise project will be used.
158+
159+
* `description` - (Optional, String) Specifies the description of the desktop pool.
160+
161+
* `tags` - (Optional, Map) Specifies the key/value pairs to associate with the desktop pool.
162+
163+
* `in_maintenance_mode` - (Optional, Bool) Specifies whether to enable maintenance mode of the desktop pool.
164+
Defaults to **false**.
165+
166+
<a name="desktop_pool_volume"></a>
167+
The `root_volume` block supports:
168+
169+
* `type` - (Required, String) Specifies the type of the volume.
170+
The valid values are as follows:
171+
+ **SAS**: High I/O disk type.
172+
+ **SSD**: Ultra-high I/O disk type.
173+
174+
* `size` - (Required, Int) Specifies the size of the volume, in GB.
175+
+ For root volume, the valid value ranges from `80` to `1,020`.
176+
+ For data volume, the valid value ranges from `10` to `8,200`.
177+
178+
<a name="desktop_pool_authorized_objects"></a>
179+
The `authorized_objects` block supports:
180+
181+
* `object_id` - (Required, String) Specifies the ID of the object.
182+
183+
* `object_type` - (Required, String) Specifies the type of the object.
184+
The valid values are as follows:
185+
+ **USER**
186+
+ **USER_GROUP**
187+
188+
* `object_name` - (Required, String) Specifies the name of the object.
189+
190+
* `user_group` - (Required, String) Specifies the permission group to which the user belongs.
191+
The valid values are as follows:
192+
+ **sudo**: Linux administrator group.
193+
+ **default**: Linux default user group.
194+
+ **administrators**: Windows administrator group.
195+
+ **users**: Windows standard user group.
196+
197+
<a name="desktop_pool_autoscale_policy"></a>
198+
The `autoscale_policy` block supports:
199+
200+
* `autoscale_type` - (Optional, String) Specifies the type of automatic scaling policy.
201+
The valid values are as follows:
202+
+ **ACCESS_CREATED**: Create desktops during accessing.
203+
+ **AUTO_CREATED**: Pre-creation desktops.
204+
205+
* `max_auto_created` - (Optional, Int) Specifies the maximum number of automatically created desktops.
206+
The valid value ranges from `1` to `1,000`.
207+
208+
* `min_idle` - (Optional, Int) Specifies the desktops will be automatically created when the number of idle desktops is
209+
less than this value.
210+
The valid value ranges from `1` to `1,000`.
211+
212+
* `once_auto_created` - (Optional, Int) Specifies the number of desktops automatically created at one time.
213+
The valid value ranges from `1` to `100`.
214+
215+
<a name="desktop_pool_security_groups"></a>
216+
The `security_groups` block supports:
217+
218+
* `id` - (Required, String, NonUpdatable) Specifies the ID of the security group.
219+
220+
## Attribute Reference
221+
222+
In addition to all arguments above, the following attributes are exported:
223+
224+
* `id` - The resource ID, also desktop pool ID.
225+
226+
* `root_volume` - The system volume configuration of the desktop pool.
227+
The [root_volume](#attr_desktop_pool_volume) structure is documented below.
228+
229+
* `data_volumes` - The list of the data volume configurations of the desktop pool.
230+
The [data_volumes](#attr_desktop_pool_volume) structure is documented below.
231+
232+
* `status` - The status of the desktop pool.
233+
+ **STEADY**
234+
+ **TEMPORARY**
235+
+ **EXIST_FROZEN**
236+
+ **UNKNOWN**
237+
238+
* `created_time` - The creation time of the desktop pool, in UTC format.
239+
240+
* `desktop_used` - The number of desktops associated with the users under the desktop pool.
241+
242+
* `product` - The product information of the desktop pool.
243+
The [product](#attr_desktop_pool_product) structure is documented below.
244+
245+
* `image_name` - The image name of the desktop pool.
246+
247+
* `image_os_type` - The image OS type of the desktop pool.
248+
249+
* `image_os_version` - The image OS version of the desktop pool.
250+
251+
* `image_os_platform` - The image OS platform of the desktop pool.
252+
253+
<a name="attr_desktop_pool_volume"></a>
254+
The `data_volumes` block supports:
255+
256+
* `id` - The ID of the volume.
257+
258+
<a name="attr_desktop_pool_product"></a>
259+
The `product` block supports:
260+
261+
* `flavor_id` - The product specification ID of the desktop pool.
262+
263+
* `type` - The product type of the desktop pool.
264+
+ **BASE**: Basic package of the product.
265+
266+
* `memory` - The product memory of the desktop pool.
267+
268+
* `cpu` - The product CPU of the desktop pool.
269+
270+
* `descriptions` - The product description of the desktop pool.
271+
272+
* `charging_mode` - The product charging mode of the desktop pool.
273+
+ **0**: The yearly/monthly billing mode.
274+
+ **1**: The pay-per-use billing mode.
275+
276+
## Timeouts
277+
278+
This resource provides the following timeouts configuration options:
279+
280+
* `create` - Default is 20 minutes.
281+
* `delete` - Default is 20 minutes.
282+
283+
## Import
284+
285+
The desktop pool can be imported using `id`, e.g.
286+
287+
```bash
288+
$ terraform import huaweicloud_workspace_desktop_pool.test <id>
289+
```
290+
291+
Please add the followings if some attributes are missing when importing the resource.
292+
293+
Note that the imported state may not be identical to your resource definition, due to some attributes missing from the
294+
API response, security or some other reason.
295+
The missing attributes include: `vpc_id`, `image_type`, `tags`, `ou_name`.
296+
It is generally recommended running `terraform plan` after importing the resource.
297+
You can then decide if changes should be applied to the resource, or the resource definition should be updated to
298+
align with the instance. Also you can ignore changes as below.
299+
300+
```hcl
301+
resource "huaweicloud_workspace_desktop_pool" "test" {
302+
...
303+
304+
lifecycle {
305+
ignore_changes = [
306+
vpc_id, image_type, tags, ou_name,
307+
]
308+
}
309+
}
310+
```

huaweicloud/provider.go

+1
Original file line numberDiff line numberDiff line change
@@ -2387,6 +2387,7 @@ func Provider() *schema.Provider {
23872387
"huaweicloud_workspace_access_policy": workspace.ResourceAccessPolicy(),
23882388
"huaweicloud_workspace_desktop_name_rule": workspace.ResourceDesktopNameRule(),
23892389
"huaweicloud_workspace_desktop": workspace.ResourceDesktop(),
2390+
"huaweicloud_workspace_desktop_pool": workspace.ResourceDesktopPool(),
23902391
"huaweicloud_workspace_policy_group": workspace.ResourcePolicyGroup(),
23912392
"huaweicloud_workspace_service": workspace.ResourceService(),
23922393
"huaweicloud_workspace_terminal_binding": workspace.ResourceTerminalBinding(),

huaweicloud/services/acceptance/acceptance.go

+8
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ var (
240240
HW_WORKSPACE_OU_NAME = os.Getenv("HW_WORKSPACE_OU_NAME")
241241
HW_WORKSPACE_APP_FILE_NAME = os.Getenv("HW_WORKSPACE_APP_FILE_NAME")
242242
HW_WORKSPACE_USER_NAMES = os.Getenv("HW_WORKSPACE_USER_NAMES")
243+
HW_WORKSPACE_DESKTOP_POOL_IMAGE_ID = os.Getenv("HW_WORKSPACE_DESKTOP_POOL_IMAGE_ID")
243244

244245
HW_FGS_AGENCY_NAME = os.Getenv("HW_FGS_AGENCY_NAME")
245246
HW_FGS_APP_AGENCY_NAME = os.Getenv("HW_FGS_APP_AGENCY_NAME")
@@ -1646,6 +1647,13 @@ func TestAccPreCheckWorkspaceOUName(t *testing.T) {
16461647
}
16471648
}
16481649

1650+
// lintignore:AT003
1651+
func TestAccPreCheckWorkspaceDesktopPoolImageId(t *testing.T) {
1652+
if HW_WORKSPACE_DESKTOP_POOL_IMAGE_ID == "" {
1653+
t.Skip("HW_WORKSPACE_DESKTOP_POOL_IMAGE_ID must be set for Workspace desktop pool acceptance tests.")
1654+
}
1655+
}
1656+
16491657
// lintignore:AT003
16501658
func TestAccPreCheckWorkspaceAppFileName(t *testing.T) {
16511659
if HW_WORKSPACE_APP_FILE_NAME == "" {

0 commit comments

Comments
 (0)