/
elasticPool.go
450 lines (393 loc) · 18.1 KB
/
elasticPool.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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package azuredevops
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-azuredevops/sdk/v2/go/azuredevops/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages Elastic pool within Azure DevOps.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-azuredevops/sdk/v2/go/azuredevops"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleProject, err := azuredevops.NewProject(ctx, "exampleProject", &azuredevops.ProjectArgs{
// Visibility: pulumi.String("private"),
// VersionControl: pulumi.String("Git"),
// WorkItemTemplate: pulumi.String("Agile"),
// Description: pulumi.String("Managed by Terraform"),
// })
// if err != nil {
// return err
// }
// exampleServiceEndpointAzureRM, err := azuredevops.NewServiceEndpointAzureRM(ctx, "exampleServiceEndpointAzureRM", &azuredevops.ServiceEndpointAzureRMArgs{
// ProjectId: exampleProject.ID(),
// ServiceEndpointName: pulumi.String("Example Azure Connection"),
// Description: pulumi.String("Managed by Terraform"),
// ServiceEndpointAuthenticationScheme: pulumi.String("ServicePrincipal"),
// Credentials: &azuredevops.ServiceEndpointAzureRMCredentialsArgs{
// Serviceprincipalid: pulumi.String("00000000-0000-0000-0000-000000000000"),
// Serviceprincipalkey: pulumi.String("00000000-0000-0000-0000-000000000000"),
// },
// AzurermSpnTenantid: pulumi.String("00000000-0000-0000-0000-000000000000"),
// AzurermSubscriptionId: pulumi.String("00000000-0000-0000-0000-000000000000"),
// AzurermSubscriptionName: pulumi.String("Subscription Name"),
// })
// if err != nil {
// return err
// }
// _, err = azuredevops.NewElasticPool(ctx, "exampleElasticPool", &azuredevops.ElasticPoolArgs{
// ServiceEndpointId: exampleServiceEndpointAzureRM.ID(),
// ServiceEndpointScope: exampleProject.ID(),
// DesiredIdle: pulumi.Int(2),
// MaxCapacity: pulumi.Int(3),
// AzureResourceId: pulumi.String("/subscriptions/<Subscription Id>/resourceGroups/<Resource Name>/providers/Microsoft.Compute/virtualMachineScaleSets/<VMSS Name>"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Relevant Links
//
// - [Azure DevOps Service REST API 7.0 - Elastic Pools](https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/elasticpools/create?view=azure-devops-rest-7.0)
//
// ## Import
//
// Azure DevOps Agent Pools can be imported using the Elastic pool ID, e.g.
//
// ```sh
// $ pulumi import azuredevops:index/elasticPool:ElasticPool example 0
// ```
type ElasticPool struct {
pulumi.CustomResourceState
// Set whether agents should be configured to run with interactive UI. Defaults to `false`.
AgentInteractiveUi pulumi.BoolPtrOutput `pulumi:"agentInteractiveUi"`
// Specifies whether a queue should be automatically provisioned for each project collection. Defaults to `false`.
AutoProvision pulumi.BoolPtrOutput `pulumi:"autoProvision"`
// Specifies whether or not agents within the pool should be automatically updated. Defaults to `true`.
AutoUpdate pulumi.BoolPtrOutput `pulumi:"autoUpdate"`
// The ID of the Azure resource.
AzureResourceId pulumi.StringOutput `pulumi:"azureResourceId"`
// Number of agents to keep on standby.
DesiredIdle pulumi.IntOutput `pulumi:"desiredIdle"`
// Maximum number of virtual machines in the scale set.
MaxCapacity pulumi.IntOutput `pulumi:"maxCapacity"`
// The name of the Elastic pool.
Name pulumi.StringOutput `pulumi:"name"`
// Tear down virtual machines after every use. Defaults to `false`.
RecycleAfterEachUse pulumi.BoolPtrOutput `pulumi:"recycleAfterEachUse"`
// The ID of Service Endpoint used to connect to Azure.
ServiceEndpointId pulumi.StringOutput `pulumi:"serviceEndpointId"`
// The Project ID of Service Endpoint belongs to.
ServiceEndpointScope pulumi.StringOutput `pulumi:"serviceEndpointScope"`
// Delay in minutes before deleting excess idle agents. Defaults to `30`.
TimeToLiveMinutes pulumi.IntPtrOutput `pulumi:"timeToLiveMinutes"`
}
// NewElasticPool registers a new resource with the given unique name, arguments, and options.
func NewElasticPool(ctx *pulumi.Context,
name string, args *ElasticPoolArgs, opts ...pulumi.ResourceOption) (*ElasticPool, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.AzureResourceId == nil {
return nil, errors.New("invalid value for required argument 'AzureResourceId'")
}
if args.DesiredIdle == nil {
return nil, errors.New("invalid value for required argument 'DesiredIdle'")
}
if args.MaxCapacity == nil {
return nil, errors.New("invalid value for required argument 'MaxCapacity'")
}
if args.ServiceEndpointId == nil {
return nil, errors.New("invalid value for required argument 'ServiceEndpointId'")
}
if args.ServiceEndpointScope == nil {
return nil, errors.New("invalid value for required argument 'ServiceEndpointScope'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource ElasticPool
err := ctx.RegisterResource("azuredevops:index/elasticPool:ElasticPool", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetElasticPool gets an existing ElasticPool resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetElasticPool(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ElasticPoolState, opts ...pulumi.ResourceOption) (*ElasticPool, error) {
var resource ElasticPool
err := ctx.ReadResource("azuredevops:index/elasticPool:ElasticPool", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ElasticPool resources.
type elasticPoolState struct {
// Set whether agents should be configured to run with interactive UI. Defaults to `false`.
AgentInteractiveUi *bool `pulumi:"agentInteractiveUi"`
// Specifies whether a queue should be automatically provisioned for each project collection. Defaults to `false`.
AutoProvision *bool `pulumi:"autoProvision"`
// Specifies whether or not agents within the pool should be automatically updated. Defaults to `true`.
AutoUpdate *bool `pulumi:"autoUpdate"`
// The ID of the Azure resource.
AzureResourceId *string `pulumi:"azureResourceId"`
// Number of agents to keep on standby.
DesiredIdle *int `pulumi:"desiredIdle"`
// Maximum number of virtual machines in the scale set.
MaxCapacity *int `pulumi:"maxCapacity"`
// The name of the Elastic pool.
Name *string `pulumi:"name"`
// Tear down virtual machines after every use. Defaults to `false`.
RecycleAfterEachUse *bool `pulumi:"recycleAfterEachUse"`
// The ID of Service Endpoint used to connect to Azure.
ServiceEndpointId *string `pulumi:"serviceEndpointId"`
// The Project ID of Service Endpoint belongs to.
ServiceEndpointScope *string `pulumi:"serviceEndpointScope"`
// Delay in minutes before deleting excess idle agents. Defaults to `30`.
TimeToLiveMinutes *int `pulumi:"timeToLiveMinutes"`
}
type ElasticPoolState struct {
// Set whether agents should be configured to run with interactive UI. Defaults to `false`.
AgentInteractiveUi pulumi.BoolPtrInput
// Specifies whether a queue should be automatically provisioned for each project collection. Defaults to `false`.
AutoProvision pulumi.BoolPtrInput
// Specifies whether or not agents within the pool should be automatically updated. Defaults to `true`.
AutoUpdate pulumi.BoolPtrInput
// The ID of the Azure resource.
AzureResourceId pulumi.StringPtrInput
// Number of agents to keep on standby.
DesiredIdle pulumi.IntPtrInput
// Maximum number of virtual machines in the scale set.
MaxCapacity pulumi.IntPtrInput
// The name of the Elastic pool.
Name pulumi.StringPtrInput
// Tear down virtual machines after every use. Defaults to `false`.
RecycleAfterEachUse pulumi.BoolPtrInput
// The ID of Service Endpoint used to connect to Azure.
ServiceEndpointId pulumi.StringPtrInput
// The Project ID of Service Endpoint belongs to.
ServiceEndpointScope pulumi.StringPtrInput
// Delay in minutes before deleting excess idle agents. Defaults to `30`.
TimeToLiveMinutes pulumi.IntPtrInput
}
func (ElasticPoolState) ElementType() reflect.Type {
return reflect.TypeOf((*elasticPoolState)(nil)).Elem()
}
type elasticPoolArgs struct {
// Set whether agents should be configured to run with interactive UI. Defaults to `false`.
AgentInteractiveUi *bool `pulumi:"agentInteractiveUi"`
// Specifies whether a queue should be automatically provisioned for each project collection. Defaults to `false`.
AutoProvision *bool `pulumi:"autoProvision"`
// Specifies whether or not agents within the pool should be automatically updated. Defaults to `true`.
AutoUpdate *bool `pulumi:"autoUpdate"`
// The ID of the Azure resource.
AzureResourceId string `pulumi:"azureResourceId"`
// Number of agents to keep on standby.
DesiredIdle int `pulumi:"desiredIdle"`
// Maximum number of virtual machines in the scale set.
MaxCapacity int `pulumi:"maxCapacity"`
// The name of the Elastic pool.
Name *string `pulumi:"name"`
// Tear down virtual machines after every use. Defaults to `false`.
RecycleAfterEachUse *bool `pulumi:"recycleAfterEachUse"`
// The ID of Service Endpoint used to connect to Azure.
ServiceEndpointId string `pulumi:"serviceEndpointId"`
// The Project ID of Service Endpoint belongs to.
ServiceEndpointScope string `pulumi:"serviceEndpointScope"`
// Delay in minutes before deleting excess idle agents. Defaults to `30`.
TimeToLiveMinutes *int `pulumi:"timeToLiveMinutes"`
}
// The set of arguments for constructing a ElasticPool resource.
type ElasticPoolArgs struct {
// Set whether agents should be configured to run with interactive UI. Defaults to `false`.
AgentInteractiveUi pulumi.BoolPtrInput
// Specifies whether a queue should be automatically provisioned for each project collection. Defaults to `false`.
AutoProvision pulumi.BoolPtrInput
// Specifies whether or not agents within the pool should be automatically updated. Defaults to `true`.
AutoUpdate pulumi.BoolPtrInput
// The ID of the Azure resource.
AzureResourceId pulumi.StringInput
// Number of agents to keep on standby.
DesiredIdle pulumi.IntInput
// Maximum number of virtual machines in the scale set.
MaxCapacity pulumi.IntInput
// The name of the Elastic pool.
Name pulumi.StringPtrInput
// Tear down virtual machines after every use. Defaults to `false`.
RecycleAfterEachUse pulumi.BoolPtrInput
// The ID of Service Endpoint used to connect to Azure.
ServiceEndpointId pulumi.StringInput
// The Project ID of Service Endpoint belongs to.
ServiceEndpointScope pulumi.StringInput
// Delay in minutes before deleting excess idle agents. Defaults to `30`.
TimeToLiveMinutes pulumi.IntPtrInput
}
func (ElasticPoolArgs) ElementType() reflect.Type {
return reflect.TypeOf((*elasticPoolArgs)(nil)).Elem()
}
type ElasticPoolInput interface {
pulumi.Input
ToElasticPoolOutput() ElasticPoolOutput
ToElasticPoolOutputWithContext(ctx context.Context) ElasticPoolOutput
}
func (*ElasticPool) ElementType() reflect.Type {
return reflect.TypeOf((**ElasticPool)(nil)).Elem()
}
func (i *ElasticPool) ToElasticPoolOutput() ElasticPoolOutput {
return i.ToElasticPoolOutputWithContext(context.Background())
}
func (i *ElasticPool) ToElasticPoolOutputWithContext(ctx context.Context) ElasticPoolOutput {
return pulumi.ToOutputWithContext(ctx, i).(ElasticPoolOutput)
}
// ElasticPoolArrayInput is an input type that accepts ElasticPoolArray and ElasticPoolArrayOutput values.
// You can construct a concrete instance of `ElasticPoolArrayInput` via:
//
// ElasticPoolArray{ ElasticPoolArgs{...} }
type ElasticPoolArrayInput interface {
pulumi.Input
ToElasticPoolArrayOutput() ElasticPoolArrayOutput
ToElasticPoolArrayOutputWithContext(context.Context) ElasticPoolArrayOutput
}
type ElasticPoolArray []ElasticPoolInput
func (ElasticPoolArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ElasticPool)(nil)).Elem()
}
func (i ElasticPoolArray) ToElasticPoolArrayOutput() ElasticPoolArrayOutput {
return i.ToElasticPoolArrayOutputWithContext(context.Background())
}
func (i ElasticPoolArray) ToElasticPoolArrayOutputWithContext(ctx context.Context) ElasticPoolArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ElasticPoolArrayOutput)
}
// ElasticPoolMapInput is an input type that accepts ElasticPoolMap and ElasticPoolMapOutput values.
// You can construct a concrete instance of `ElasticPoolMapInput` via:
//
// ElasticPoolMap{ "key": ElasticPoolArgs{...} }
type ElasticPoolMapInput interface {
pulumi.Input
ToElasticPoolMapOutput() ElasticPoolMapOutput
ToElasticPoolMapOutputWithContext(context.Context) ElasticPoolMapOutput
}
type ElasticPoolMap map[string]ElasticPoolInput
func (ElasticPoolMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ElasticPool)(nil)).Elem()
}
func (i ElasticPoolMap) ToElasticPoolMapOutput() ElasticPoolMapOutput {
return i.ToElasticPoolMapOutputWithContext(context.Background())
}
func (i ElasticPoolMap) ToElasticPoolMapOutputWithContext(ctx context.Context) ElasticPoolMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ElasticPoolMapOutput)
}
type ElasticPoolOutput struct{ *pulumi.OutputState }
func (ElasticPoolOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ElasticPool)(nil)).Elem()
}
func (o ElasticPoolOutput) ToElasticPoolOutput() ElasticPoolOutput {
return o
}
func (o ElasticPoolOutput) ToElasticPoolOutputWithContext(ctx context.Context) ElasticPoolOutput {
return o
}
// Set whether agents should be configured to run with interactive UI. Defaults to `false`.
func (o ElasticPoolOutput) AgentInteractiveUi() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.BoolPtrOutput { return v.AgentInteractiveUi }).(pulumi.BoolPtrOutput)
}
// Specifies whether a queue should be automatically provisioned for each project collection. Defaults to `false`.
func (o ElasticPoolOutput) AutoProvision() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.BoolPtrOutput { return v.AutoProvision }).(pulumi.BoolPtrOutput)
}
// Specifies whether or not agents within the pool should be automatically updated. Defaults to `true`.
func (o ElasticPoolOutput) AutoUpdate() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.BoolPtrOutput { return v.AutoUpdate }).(pulumi.BoolPtrOutput)
}
// The ID of the Azure resource.
func (o ElasticPoolOutput) AzureResourceId() pulumi.StringOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.StringOutput { return v.AzureResourceId }).(pulumi.StringOutput)
}
// Number of agents to keep on standby.
func (o ElasticPoolOutput) DesiredIdle() pulumi.IntOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.IntOutput { return v.DesiredIdle }).(pulumi.IntOutput)
}
// Maximum number of virtual machines in the scale set.
func (o ElasticPoolOutput) MaxCapacity() pulumi.IntOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.IntOutput { return v.MaxCapacity }).(pulumi.IntOutput)
}
// The name of the Elastic pool.
func (o ElasticPoolOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Tear down virtual machines after every use. Defaults to `false`.
func (o ElasticPoolOutput) RecycleAfterEachUse() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.BoolPtrOutput { return v.RecycleAfterEachUse }).(pulumi.BoolPtrOutput)
}
// The ID of Service Endpoint used to connect to Azure.
func (o ElasticPoolOutput) ServiceEndpointId() pulumi.StringOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.StringOutput { return v.ServiceEndpointId }).(pulumi.StringOutput)
}
// The Project ID of Service Endpoint belongs to.
func (o ElasticPoolOutput) ServiceEndpointScope() pulumi.StringOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.StringOutput { return v.ServiceEndpointScope }).(pulumi.StringOutput)
}
// Delay in minutes before deleting excess idle agents. Defaults to `30`.
func (o ElasticPoolOutput) TimeToLiveMinutes() pulumi.IntPtrOutput {
return o.ApplyT(func(v *ElasticPool) pulumi.IntPtrOutput { return v.TimeToLiveMinutes }).(pulumi.IntPtrOutput)
}
type ElasticPoolArrayOutput struct{ *pulumi.OutputState }
func (ElasticPoolArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ElasticPool)(nil)).Elem()
}
func (o ElasticPoolArrayOutput) ToElasticPoolArrayOutput() ElasticPoolArrayOutput {
return o
}
func (o ElasticPoolArrayOutput) ToElasticPoolArrayOutputWithContext(ctx context.Context) ElasticPoolArrayOutput {
return o
}
func (o ElasticPoolArrayOutput) Index(i pulumi.IntInput) ElasticPoolOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ElasticPool {
return vs[0].([]*ElasticPool)[vs[1].(int)]
}).(ElasticPoolOutput)
}
type ElasticPoolMapOutput struct{ *pulumi.OutputState }
func (ElasticPoolMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ElasticPool)(nil)).Elem()
}
func (o ElasticPoolMapOutput) ToElasticPoolMapOutput() ElasticPoolMapOutput {
return o
}
func (o ElasticPoolMapOutput) ToElasticPoolMapOutputWithContext(ctx context.Context) ElasticPoolMapOutput {
return o
}
func (o ElasticPoolMapOutput) MapIndex(k pulumi.StringInput) ElasticPoolOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ElasticPool {
return vs[0].(map[string]*ElasticPool)[vs[1].(string)]
}).(ElasticPoolOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ElasticPoolInput)(nil)).Elem(), &ElasticPool{})
pulumi.RegisterInputType(reflect.TypeOf((*ElasticPoolArrayInput)(nil)).Elem(), ElasticPoolArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ElasticPoolMapInput)(nil)).Elem(), ElasticPoolMap{})
pulumi.RegisterOutputType(ElasticPoolOutput{})
pulumi.RegisterOutputType(ElasticPoolArrayOutput{})
pulumi.RegisterOutputType(ElasticPoolMapOutput{})
}