/
directories.go
254 lines (249 loc) · 9.54 KB
/
directories.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
package workspaces
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/workspaces"
"github.com/aws/aws-sdk-go-v2/service/workspaces/types"
"github.com/cloudquery/cloudquery/plugins/source/aws/client"
"github.com/cloudquery/cq-provider-sdk/provider/diag"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
)
//go:generate cq-gen --resource directories --config gen.hcl --output .
func Directories() *schema.Table {
return &schema.Table{
Name: "aws_workspaces_directories",
Description: "Describes a directory that is used with Amazon WorkSpaces.",
Resolver: fetchWorkspacesDirectories,
Multiplex: client.ServiceAccountRegionMultiplexer("workspaces"),
IgnoreError: client.IgnoreCommonErrors,
DeleteFilter: client.DeleteAccountRegionFilter,
Options: schema.TableCreationOptions{PrimaryKeys: []string{"id"}},
Columns: []schema.Column{
{
Name: "account_id",
Description: "The AWS Account ID of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveAWSAccount,
},
{
Name: "region",
Description: "The AWS Region of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveAWSRegion,
},
{
Name: "arn",
Description: "The Amazon Resource Name (ARN) for the workspaces directory",
Type: schema.TypeString,
Resolver: client.ResolveARN(client.WorkspacesService, func(resource *schema.Resource) ([]string, error) {
return []string{"directory", *resource.Item.(types.WorkspaceDirectory).DirectoryId}, nil
}),
},
{
Name: "alias",
Description: "The directory alias.",
Type: schema.TypeString,
},
{
Name: "customer_user_name",
Description: "The user name for the service account.",
Type: schema.TypeString,
},
{
Name: "id",
Description: "The directory identifier.",
Type: schema.TypeString,
Resolver: schema.PathResolver("DirectoryId"),
},
{
Name: "name",
Description: "The name of the directory.",
Type: schema.TypeString,
Resolver: schema.PathResolver("DirectoryName"),
},
{
Name: "type",
Description: "The directory type.",
Type: schema.TypeString,
Resolver: schema.PathResolver("DirectoryType"),
},
{
Name: "dns_ip_addresses",
Description: "The IP addresses of the DNS servers for the directory.",
Type: schema.TypeStringArray,
},
{
Name: "iam_role_id",
Description: "The identifier of the IAM role",
Type: schema.TypeString,
},
{
Name: "ip_group_ids",
Description: "The identifiers of the IP access control groups associated with the directory.",
Type: schema.TypeStringArray,
IgnoreInTests: true,
},
{
Name: "registration_code",
Description: "The registration code for the directory",
Type: schema.TypeString,
},
{
Name: "change_compute_type",
Description: "Specifies whether users can change the compute type (bundle) for their WorkSpace.",
Type: schema.TypeString,
Resolver: schema.PathResolver("SelfservicePermissions.ChangeComputeType"),
},
{
Name: "increase_volume_size",
Description: "Specifies whether users can increase the volume size of the drives on their WorkSpace.",
Type: schema.TypeString,
Resolver: schema.PathResolver("SelfservicePermissions.IncreaseVolumeSize"),
},
{
Name: "rebuild_workspace",
Description: "Specifies whether users can rebuild the operating system of a WorkSpace to its original state.",
Type: schema.TypeString,
Resolver: schema.PathResolver("SelfservicePermissions.RebuildWorkspace"),
},
{
Name: "restart_workspace",
Description: "Specifies whether users can restart their WorkSpace.",
Type: schema.TypeString,
Resolver: schema.PathResolver("SelfservicePermissions.RestartWorkspace"),
},
{
Name: "switch_running_mode",
Description: "Specifies whether users can switch the running mode of their WorkSpace.",
Type: schema.TypeString,
Resolver: schema.PathResolver("SelfservicePermissions.SwitchRunningMode"),
},
{
Name: "state",
Description: "The state of the directory's registration with Amazon WorkSpaces",
Type: schema.TypeString,
},
{
Name: "subnet_ids",
Description: "The identifiers of the subnets used with the directory.",
Type: schema.TypeStringArray,
},
{
Name: "tenancy",
Description: "Specifies whether the directory is dedicated or shared",
Type: schema.TypeString,
},
{
Name: "device_type_android",
Description: "Indicates whether users can use Android and Android-compatible Chrome OS devices to access their WorkSpaces.",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceAccessProperties.DeviceTypeAndroid"),
},
{
Name: "device_type_chrome_os",
Description: "Indicates whether users can use Chromebooks to access their WorkSpaces.",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceAccessProperties.DeviceTypeChromeOs"),
},
{
Name: "device_type_ios",
Description: "Indicates whether users can use iOS devices to access their WorkSpaces.",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceAccessProperties.DeviceTypeIos"),
},
{
Name: "device_type_linux",
Description: "Indicates whether users can use Linux clients to access their WorkSpaces.",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceAccessProperties.DeviceTypeLinux"),
},
{
Name: "device_type_osx",
Description: "Indicates whether users can use macOS clients to access their WorkSpaces.",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceAccessProperties.DeviceTypeOsx"),
},
{
Name: "device_type_web",
Description: "Indicates whether users can access their WorkSpaces through a web browser.",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceAccessProperties.DeviceTypeWeb"),
},
{
Name: "device_type_windows",
Description: "Indicates whether users can use Windows clients to access their WorkSpaces.",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceAccessProperties.DeviceTypeWindows"),
},
{
Name: "device_type_zero_client",
Description: "Indicates whether users can use zero client devices to access their WorkSpaces.",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceAccessProperties.DeviceTypeZeroClient"),
},
{
Name: "custom_security_group_id",
Description: "The identifier of the default security group to apply to WorkSpaces when they are created",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceCreationProperties.CustomSecurityGroupId"),
IgnoreInTests: true,
},
{
Name: "default_ou",
Description: "The organizational unit (OU) in the directory for the WorkSpace machine accounts.",
Type: schema.TypeString,
Resolver: schema.PathResolver("WorkspaceCreationProperties.DefaultOu"),
IgnoreInTests: true,
},
{
Name: "enable_internet_access",
Description: "Specifies whether to automatically assign an Elastic public IP address to WorkSpaces in this directory by default",
Type: schema.TypeBool,
Resolver: schema.PathResolver("WorkspaceCreationProperties.EnableInternetAccess"),
},
{
Name: "enable_maintenance_mode",
Description: "Specifies whether maintenance mode is enabled for WorkSpaces",
Type: schema.TypeBool,
Resolver: schema.PathResolver("WorkspaceCreationProperties.EnableMaintenanceMode"),
},
{
Name: "enable_work_docs",
Description: "Specifies whether the directory is enabled for Amazon WorkDocs.",
Type: schema.TypeBool,
Resolver: schema.PathResolver("WorkspaceCreationProperties.EnableWorkDocs"),
},
{
Name: "user_enabled_as_local_administrator",
Description: "Specifies whether WorkSpace users are local administrators on their WorkSpaces.",
Type: schema.TypeBool,
Resolver: schema.PathResolver("WorkspaceCreationProperties.UserEnabledAsLocalAdministrator"),
},
{
Name: "workspace_security_group_id",
Description: "The identifier of the security group that is assigned to new WorkSpaces.",
Type: schema.TypeString,
},
},
}
}
// ====================================================================================================================
// Table Resolver Functions
// ====================================================================================================================
func fetchWorkspacesDirectories(ctx context.Context, meta schema.ClientMeta, _ *schema.Resource, res chan<- interface{}) error {
c := meta.(*client.Client)
svc := c.Services().Workspaces
input := workspaces.DescribeWorkspaceDirectoriesInput{}
for {
output, err := svc.DescribeWorkspaceDirectories(ctx, &input)
if err != nil {
return diag.WrapError(err)
}
res <- output.Directories
if aws.ToString(output.NextToken) == "" {
break
}
input.NextToken = output.NextToken
}
return nil
}