/
poolV1.go
570 lines (510 loc) · 18.3 KB
/
poolV1.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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package loadbalancer
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Manages a V1 load balancer pool resource within OpenStack.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-openstack/sdk/v2/go/openstack/loadbalancer"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := loadbalancer.NewPoolV1(ctx, "pool1", &loadbalancer.PoolV1Args{
// LbMethod: pulumi.String("ROUND_ROBIN"),
// LbProvider: pulumi.String("haproxy"),
// MonitorIds: pulumi.StringArray{
// pulumi.String("67890"),
// },
// Protocol: pulumi.String("HTTP"),
// SubnetId: pulumi.String("12345"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ## Complete Load Balancing Stack Example
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-openstack/sdk/v2/go/openstack/compute"
// "github.com/pulumi/pulumi-openstack/sdk/v2/go/openstack/loadbalancer"
// "github.com/pulumi/pulumi-openstack/sdk/v2/go/openstack/networking"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// network1, err := networking.NewNetwork(ctx, "network1", &networking.NetworkArgs{
// AdminStateUp: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// subnet1, err := networking.NewSubnet(ctx, "subnet1", &networking.SubnetArgs{
// Cidr: pulumi.String("192.168.199.0/24"),
// IpVersion: pulumi.Int(4),
// NetworkId: network1.ID(),
// })
// if err != nil {
// return err
// }
// secgroup1, err := compute.NewSecGroup(ctx, "secgroup1", &compute.SecGroupArgs{
// Description: pulumi.String("Rules for secgroup_1"),
// Rules: compute.SecGroupRuleArray{
// &compute.SecGroupRuleArgs{
// Cidr: pulumi.String("0.0.0.0/0"),
// FromPort: pulumi.Int(-1),
// IpProtocol: pulumi.String("icmp"),
// ToPort: pulumi.Int(-1),
// },
// &compute.SecGroupRuleArgs{
// Cidr: pulumi.String("0.0.0.0/0"),
// FromPort: pulumi.Int(80),
// IpProtocol: pulumi.String("tcp"),
// ToPort: pulumi.Int(80),
// },
// },
// })
// if err != nil {
// return err
// }
// instance1, err := compute.NewInstance(ctx, "instance1", &compute.InstanceArgs{
// Networks: compute.InstanceNetworkArray{
// &compute.InstanceNetworkArgs{
// Uuid: network1.ID(),
// },
// },
// SecurityGroups: pulumi.Array{
// pulumi.String("default"),
// secgroup1.Name,
// },
// })
// if err != nil {
// return err
// }
// instance2, err := compute.NewInstance(ctx, "instance2", &compute.InstanceArgs{
// Networks: compute.InstanceNetworkArray{
// &compute.InstanceNetworkArgs{
// Uuid: network1.ID(),
// },
// },
// SecurityGroups: pulumi.Array{
// pulumi.String("default"),
// secgroup1.Name,
// },
// })
// if err != nil {
// return err
// }
// monitor1, err := loadbalancer.NewMonitorV1(ctx, "monitor1", &loadbalancer.MonitorV1Args{
// AdminStateUp: pulumi.String("true"),
// Delay: pulumi.Int(30),
// MaxRetries: pulumi.Int(3),
// Timeout: pulumi.Int(5),
// Type: pulumi.String("TCP"),
// })
// if err != nil {
// return err
// }
// pool1, err := loadbalancer.NewPoolV1(ctx, "pool1", &loadbalancer.PoolV1Args{
// LbMethod: pulumi.String("ROUND_ROBIN"),
// MonitorIds: pulumi.StringArray{
// monitor1.ID(),
// },
// Protocol: pulumi.String("TCP"),
// SubnetId: subnet1.ID(),
// })
// if err != nil {
// return err
// }
// _, err = loadbalancer.NewMemberV1(ctx, "member1", &loadbalancer.MemberV1Args{
// Address: instance1.AccessIpV4,
// PoolId: pool1.ID(),
// Port: pulumi.Int(80),
// })
// if err != nil {
// return err
// }
// _, err = loadbalancer.NewMemberV1(ctx, "member2", &loadbalancer.MemberV1Args{
// Address: instance2.AccessIpV4,
// PoolId: pool1.ID(),
// Port: pulumi.Int(80),
// })
// if err != nil {
// return err
// }
// _, err = loadbalancer.NewVip(ctx, "vip1", &loadbalancer.VipArgs{
// PoolId: pool1.ID(),
// Port: pulumi.Int(80),
// Protocol: pulumi.String("TCP"),
// SubnetId: subnet1.ID(),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Notes
//
// The `member` block is deprecated in favor of the `loadbalancer.MemberV1` resource.
//
// ## Import
//
// Load Balancer Pools can be imported using the `id`, e.g.
//
// ```sh
// $ pulumi import openstack:loadbalancer/poolV1:PoolV1 pool_1 b255e6ba-02ad-43e6-8951-3428ca26b713
// ```
type PoolV1 struct {
pulumi.CustomResourceState
// The algorithm used to distribute load between the
// members of the pool. The current specification supports 'ROUND_ROBIN' and
// 'LEAST_CONNECTIONS' as valid values for this attribute.
LbMethod pulumi.StringOutput `pulumi:"lbMethod"`
// The backend load balancing provider. For example:
// `haproxy`, `F5`, etc.
LbProvider pulumi.StringOutput `pulumi:"lbProvider"`
// A list of IDs of monitors to associate with the
// pool.
MonitorIds pulumi.StringArrayOutput `pulumi:"monitorIds"`
// The name of the pool. Changing this updates the name of
// the existing pool.
Name pulumi.StringOutput `pulumi:"name"`
// The protocol used by the pool members, you can use
// either 'TCP, 'HTTP', or 'HTTPS'. Changing this creates a new pool.
Protocol pulumi.StringOutput `pulumi:"protocol"`
// The region in which to obtain the V2 Networking client.
// A Networking client is needed to create an LB pool. If omitted, the
// `region` argument of the provider is used. Changing this creates a new
// LB pool.
Region pulumi.StringOutput `pulumi:"region"`
// The network on which the members of the pool will be
// located. Only members that are on this network can be added to the pool.
// Changing this creates a new pool.
SubnetId pulumi.StringOutput `pulumi:"subnetId"`
// The owner of the member. Required if admin wants to
// create a pool member for another tenant. Changing this creates a new member.
TenantId pulumi.StringOutput `pulumi:"tenantId"`
}
// NewPoolV1 registers a new resource with the given unique name, arguments, and options.
func NewPoolV1(ctx *pulumi.Context,
name string, args *PoolV1Args, opts ...pulumi.ResourceOption) (*PoolV1, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.LbMethod == nil {
return nil, errors.New("invalid value for required argument 'LbMethod'")
}
if args.Protocol == nil {
return nil, errors.New("invalid value for required argument 'Protocol'")
}
if args.SubnetId == nil {
return nil, errors.New("invalid value for required argument 'SubnetId'")
}
var resource PoolV1
err := ctx.RegisterResource("openstack:loadbalancer/poolV1:PoolV1", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetPoolV1 gets an existing PoolV1 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 GetPoolV1(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *PoolV1State, opts ...pulumi.ResourceOption) (*PoolV1, error) {
var resource PoolV1
err := ctx.ReadResource("openstack:loadbalancer/poolV1:PoolV1", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering PoolV1 resources.
type poolV1State struct {
// The algorithm used to distribute load between the
// members of the pool. The current specification supports 'ROUND_ROBIN' and
// 'LEAST_CONNECTIONS' as valid values for this attribute.
LbMethod *string `pulumi:"lbMethod"`
// The backend load balancing provider. For example:
// `haproxy`, `F5`, etc.
LbProvider *string `pulumi:"lbProvider"`
// A list of IDs of monitors to associate with the
// pool.
MonitorIds []string `pulumi:"monitorIds"`
// The name of the pool. Changing this updates the name of
// the existing pool.
Name *string `pulumi:"name"`
// The protocol used by the pool members, you can use
// either 'TCP, 'HTTP', or 'HTTPS'. Changing this creates a new pool.
Protocol *string `pulumi:"protocol"`
// The region in which to obtain the V2 Networking client.
// A Networking client is needed to create an LB pool. If omitted, the
// `region` argument of the provider is used. Changing this creates a new
// LB pool.
Region *string `pulumi:"region"`
// The network on which the members of the pool will be
// located. Only members that are on this network can be added to the pool.
// Changing this creates a new pool.
SubnetId *string `pulumi:"subnetId"`
// The owner of the member. Required if admin wants to
// create a pool member for another tenant. Changing this creates a new member.
TenantId *string `pulumi:"tenantId"`
}
type PoolV1State struct {
// The algorithm used to distribute load between the
// members of the pool. The current specification supports 'ROUND_ROBIN' and
// 'LEAST_CONNECTIONS' as valid values for this attribute.
LbMethod pulumi.StringPtrInput
// The backend load balancing provider. For example:
// `haproxy`, `F5`, etc.
LbProvider pulumi.StringPtrInput
// A list of IDs of monitors to associate with the
// pool.
MonitorIds pulumi.StringArrayInput
// The name of the pool. Changing this updates the name of
// the existing pool.
Name pulumi.StringPtrInput
// The protocol used by the pool members, you can use
// either 'TCP, 'HTTP', or 'HTTPS'. Changing this creates a new pool.
Protocol pulumi.StringPtrInput
// The region in which to obtain the V2 Networking client.
// A Networking client is needed to create an LB pool. If omitted, the
// `region` argument of the provider is used. Changing this creates a new
// LB pool.
Region pulumi.StringPtrInput
// The network on which the members of the pool will be
// located. Only members that are on this network can be added to the pool.
// Changing this creates a new pool.
SubnetId pulumi.StringPtrInput
// The owner of the member. Required if admin wants to
// create a pool member for another tenant. Changing this creates a new member.
TenantId pulumi.StringPtrInput
}
func (PoolV1State) ElementType() reflect.Type {
return reflect.TypeOf((*poolV1State)(nil)).Elem()
}
type poolV1Args struct {
// The algorithm used to distribute load between the
// members of the pool. The current specification supports 'ROUND_ROBIN' and
// 'LEAST_CONNECTIONS' as valid values for this attribute.
LbMethod string `pulumi:"lbMethod"`
// The backend load balancing provider. For example:
// `haproxy`, `F5`, etc.
LbProvider *string `pulumi:"lbProvider"`
// A list of IDs of monitors to associate with the
// pool.
MonitorIds []string `pulumi:"monitorIds"`
// The name of the pool. Changing this updates the name of
// the existing pool.
Name *string `pulumi:"name"`
// The protocol used by the pool members, you can use
// either 'TCP, 'HTTP', or 'HTTPS'. Changing this creates a new pool.
Protocol string `pulumi:"protocol"`
// The region in which to obtain the V2 Networking client.
// A Networking client is needed to create an LB pool. If omitted, the
// `region` argument of the provider is used. Changing this creates a new
// LB pool.
Region *string `pulumi:"region"`
// The network on which the members of the pool will be
// located. Only members that are on this network can be added to the pool.
// Changing this creates a new pool.
SubnetId string `pulumi:"subnetId"`
// The owner of the member. Required if admin wants to
// create a pool member for another tenant. Changing this creates a new member.
TenantId *string `pulumi:"tenantId"`
}
// The set of arguments for constructing a PoolV1 resource.
type PoolV1Args struct {
// The algorithm used to distribute load between the
// members of the pool. The current specification supports 'ROUND_ROBIN' and
// 'LEAST_CONNECTIONS' as valid values for this attribute.
LbMethod pulumi.StringInput
// The backend load balancing provider. For example:
// `haproxy`, `F5`, etc.
LbProvider pulumi.StringPtrInput
// A list of IDs of monitors to associate with the
// pool.
MonitorIds pulumi.StringArrayInput
// The name of the pool. Changing this updates the name of
// the existing pool.
Name pulumi.StringPtrInput
// The protocol used by the pool members, you can use
// either 'TCP, 'HTTP', or 'HTTPS'. Changing this creates a new pool.
Protocol pulumi.StringInput
// The region in which to obtain the V2 Networking client.
// A Networking client is needed to create an LB pool. If omitted, the
// `region` argument of the provider is used. Changing this creates a new
// LB pool.
Region pulumi.StringPtrInput
// The network on which the members of the pool will be
// located. Only members that are on this network can be added to the pool.
// Changing this creates a new pool.
SubnetId pulumi.StringInput
// The owner of the member. Required if admin wants to
// create a pool member for another tenant. Changing this creates a new member.
TenantId pulumi.StringPtrInput
}
func (PoolV1Args) ElementType() reflect.Type {
return reflect.TypeOf((*poolV1Args)(nil)).Elem()
}
type PoolV1Input interface {
pulumi.Input
ToPoolV1Output() PoolV1Output
ToPoolV1OutputWithContext(ctx context.Context) PoolV1Output
}
func (*PoolV1) ElementType() reflect.Type {
return reflect.TypeOf((*PoolV1)(nil))
}
func (i *PoolV1) ToPoolV1Output() PoolV1Output {
return i.ToPoolV1OutputWithContext(context.Background())
}
func (i *PoolV1) ToPoolV1OutputWithContext(ctx context.Context) PoolV1Output {
return pulumi.ToOutputWithContext(ctx, i).(PoolV1Output)
}
func (i *PoolV1) ToPoolV1PtrOutput() PoolV1PtrOutput {
return i.ToPoolV1PtrOutputWithContext(context.Background())
}
func (i *PoolV1) ToPoolV1PtrOutputWithContext(ctx context.Context) PoolV1PtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(PoolV1PtrOutput)
}
type PoolV1PtrInput interface {
pulumi.Input
ToPoolV1PtrOutput() PoolV1PtrOutput
ToPoolV1PtrOutputWithContext(ctx context.Context) PoolV1PtrOutput
}
type poolV1PtrType PoolV1Args
func (*poolV1PtrType) ElementType() reflect.Type {
return reflect.TypeOf((**PoolV1)(nil))
}
func (i *poolV1PtrType) ToPoolV1PtrOutput() PoolV1PtrOutput {
return i.ToPoolV1PtrOutputWithContext(context.Background())
}
func (i *poolV1PtrType) ToPoolV1PtrOutputWithContext(ctx context.Context) PoolV1PtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(PoolV1PtrOutput)
}
// PoolV1ArrayInput is an input type that accepts PoolV1Array and PoolV1ArrayOutput values.
// You can construct a concrete instance of `PoolV1ArrayInput` via:
//
// PoolV1Array{ PoolV1Args{...} }
type PoolV1ArrayInput interface {
pulumi.Input
ToPoolV1ArrayOutput() PoolV1ArrayOutput
ToPoolV1ArrayOutputWithContext(context.Context) PoolV1ArrayOutput
}
type PoolV1Array []PoolV1Input
func (PoolV1Array) ElementType() reflect.Type {
return reflect.TypeOf(([]*PoolV1)(nil))
}
func (i PoolV1Array) ToPoolV1ArrayOutput() PoolV1ArrayOutput {
return i.ToPoolV1ArrayOutputWithContext(context.Background())
}
func (i PoolV1Array) ToPoolV1ArrayOutputWithContext(ctx context.Context) PoolV1ArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(PoolV1ArrayOutput)
}
// PoolV1MapInput is an input type that accepts PoolV1Map and PoolV1MapOutput values.
// You can construct a concrete instance of `PoolV1MapInput` via:
//
// PoolV1Map{ "key": PoolV1Args{...} }
type PoolV1MapInput interface {
pulumi.Input
ToPoolV1MapOutput() PoolV1MapOutput
ToPoolV1MapOutputWithContext(context.Context) PoolV1MapOutput
}
type PoolV1Map map[string]PoolV1Input
func (PoolV1Map) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*PoolV1)(nil))
}
func (i PoolV1Map) ToPoolV1MapOutput() PoolV1MapOutput {
return i.ToPoolV1MapOutputWithContext(context.Background())
}
func (i PoolV1Map) ToPoolV1MapOutputWithContext(ctx context.Context) PoolV1MapOutput {
return pulumi.ToOutputWithContext(ctx, i).(PoolV1MapOutput)
}
type PoolV1Output struct {
*pulumi.OutputState
}
func (PoolV1Output) ElementType() reflect.Type {
return reflect.TypeOf((*PoolV1)(nil))
}
func (o PoolV1Output) ToPoolV1Output() PoolV1Output {
return o
}
func (o PoolV1Output) ToPoolV1OutputWithContext(ctx context.Context) PoolV1Output {
return o
}
func (o PoolV1Output) ToPoolV1PtrOutput() PoolV1PtrOutput {
return o.ToPoolV1PtrOutputWithContext(context.Background())
}
func (o PoolV1Output) ToPoolV1PtrOutputWithContext(ctx context.Context) PoolV1PtrOutput {
return o.ApplyT(func(v PoolV1) *PoolV1 {
return &v
}).(PoolV1PtrOutput)
}
type PoolV1PtrOutput struct {
*pulumi.OutputState
}
func (PoolV1PtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**PoolV1)(nil))
}
func (o PoolV1PtrOutput) ToPoolV1PtrOutput() PoolV1PtrOutput {
return o
}
func (o PoolV1PtrOutput) ToPoolV1PtrOutputWithContext(ctx context.Context) PoolV1PtrOutput {
return o
}
type PoolV1ArrayOutput struct{ *pulumi.OutputState }
func (PoolV1ArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]PoolV1)(nil))
}
func (o PoolV1ArrayOutput) ToPoolV1ArrayOutput() PoolV1ArrayOutput {
return o
}
func (o PoolV1ArrayOutput) ToPoolV1ArrayOutputWithContext(ctx context.Context) PoolV1ArrayOutput {
return o
}
func (o PoolV1ArrayOutput) Index(i pulumi.IntInput) PoolV1Output {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) PoolV1 {
return vs[0].([]PoolV1)[vs[1].(int)]
}).(PoolV1Output)
}
type PoolV1MapOutput struct{ *pulumi.OutputState }
func (PoolV1MapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]PoolV1)(nil))
}
func (o PoolV1MapOutput) ToPoolV1MapOutput() PoolV1MapOutput {
return o
}
func (o PoolV1MapOutput) ToPoolV1MapOutputWithContext(ctx context.Context) PoolV1MapOutput {
return o
}
func (o PoolV1MapOutput) MapIndex(k pulumi.StringInput) PoolV1Output {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) PoolV1 {
return vs[0].(map[string]PoolV1)[vs[1].(string)]
}).(PoolV1Output)
}
func init() {
pulumi.RegisterOutputType(PoolV1Output{})
pulumi.RegisterOutputType(PoolV1PtrOutput{})
pulumi.RegisterOutputType(PoolV1ArrayOutput{})
pulumi.RegisterOutputType(PoolV1MapOutput{})
}