/
loadBalancer.go
621 lines (554 loc) · 42.2 KB
/
loadBalancer.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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
// 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 cloudflare
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a Cloudflare Load Balancer resource. This sits in front of
// a number of defined pools of origins and provides various options
// for geographically-aware load balancing. Note that the load balancing
// feature must be enabled in your Cloudflare account before you can use
// this resource.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleLoadBalancerPool, err := cloudflare.NewLoadBalancerPool(ctx, "exampleLoadBalancerPool", &cloudflare.LoadBalancerPoolArgs{
// Name: pulumi.String("example-lb-pool"),
// Origins: cloudflare.LoadBalancerPoolOriginArray{
// &cloudflare.LoadBalancerPoolOriginArgs{
// Name: pulumi.String("example-1"),
// Address: pulumi.String("192.0.2.1"),
// Enabled: pulumi.Bool(false),
// },
// },
// })
// if err != nil {
// return err
// }
// // Define a load balancer which always points to a pool we define below.
// // In normal usage, would have different pools set for different pops
// // (cloudflare points-of-presence) and/or for different regions.
// // Within each pop or region we can define multiple pools in failover order.
// _, err = cloudflare.NewLoadBalancer(ctx, "exampleLoadBalancer", &cloudflare.LoadBalancerArgs{
// ZoneId: pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
// Name: pulumi.String("example-load-balancer.example.com"),
// FallbackPoolId: exampleLoadBalancerPool.ID(),
// DefaultPoolIds: pulumi.StringArray{
// exampleLoadBalancerPool.ID(),
// },
// Description: pulumi.String("example load balancer using geo-balancing"),
// Proxied: pulumi.Bool(true),
// SteeringPolicy: pulumi.String("geo"),
// PopPools: cloudflare.LoadBalancerPopPoolArray{
// &cloudflare.LoadBalancerPopPoolArgs{
// Pop: pulumi.String("LAX"),
// PoolIds: pulumi.StringArray{
// exampleLoadBalancerPool.ID(),
// },
// },
// },
// CountryPools: cloudflare.LoadBalancerCountryPoolArray{
// &cloudflare.LoadBalancerCountryPoolArgs{
// Country: pulumi.String("US"),
// PoolIds: pulumi.StringArray{
// exampleLoadBalancerPool.ID(),
// },
// },
// },
// RegionPools: cloudflare.LoadBalancerRegionPoolArray{
// &cloudflare.LoadBalancerRegionPoolArgs{
// Region: pulumi.String("WNAM"),
// PoolIds: pulumi.StringArray{
// exampleLoadBalancerPool.ID(),
// },
// },
// },
// Rules: cloudflare.LoadBalancerRuleArray{
// &cloudflare.LoadBalancerRuleArgs{
// Name: pulumi.String("example rule"),
// Condition: pulumi.String("http.request.uri.path contains \"testing\""),
// FixedResponse: &cloudflare.LoadBalancerRuleFixedResponseArgs{
// MessageBody: pulumi.String("hello"),
// StatusCode: pulumi.Int(200),
// ContentType: pulumi.String("html"),
// Location: pulumi.String("www.example.com"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// ```sh
// $ pulumi import cloudflare:index/loadBalancer:LoadBalancer example <zone_id>/<load_balancer_id>
// ```
type LoadBalancer struct {
pulumi.CustomResourceState
// Controls features that modify the routing of requests to pools and origins in response to dynamic conditions, such as during the interval between active health monitoring requests.
AdaptiveRoutings LoadBalancerAdaptiveRoutingArrayOutput `pulumi:"adaptiveRoutings"`
// A set containing mappings of country codes to a list of pool IDs (ordered by their failover priority) for the given country.
CountryPools LoadBalancerCountryPoolArrayOutput `pulumi:"countryPools"`
// The RFC3339 timestamp of when the load balancer was created.
CreatedOn pulumi.StringOutput `pulumi:"createdOn"`
// A list of pool IDs ordered by their failover priority. Used whenever `popPools`/`countryPools`/`regionPools` are not defined.
DefaultPoolIds pulumi.StringArrayOutput `pulumi:"defaultPoolIds"`
// Free text description.
Description pulumi.StringPtrOutput `pulumi:"description"`
// Enable or disable the load balancer. Defaults to `true`.
Enabled pulumi.BoolPtrOutput `pulumi:"enabled"`
// The pool ID to use when all other pools are detected as unhealthy.
FallbackPoolId pulumi.StringOutput `pulumi:"fallbackPoolId"`
// Controls location-based steering for non-proxied requests.
LocationStrategies LoadBalancerLocationStrategyArrayOutput `pulumi:"locationStrategies"`
// The RFC3339 timestamp of when the load balancer was last modified.
ModifiedOn pulumi.StringOutput `pulumi:"modifiedOn"`
// Human readable name for this rule.
Name pulumi.StringOutput `pulumi:"name"`
// A set containing mappings of Cloudflare Point-of-Presence (PoP) identifiers to a list of pool IDs (ordered by their failover priority) for the PoP (datacenter). This feature is only available to enterprise customers.
PopPools LoadBalancerPopPoolArrayOutput `pulumi:"popPools"`
// Whether the hostname gets Cloudflare's origin protection. Defaults to `false`. Conflicts with `ttl`.
Proxied pulumi.BoolPtrOutput `pulumi:"proxied"`
// Configures pool weights. When `steering_policy="random"`, a random pool is selected with probability proportional to pool weights. When `steering_policy="leastOutstandingRequests"`, pool weights are used to scale each pool's outstanding requests. When `steering_policy="leastConnections"`, pool weights are used to scale each pool's open connections.
RandomSteerings LoadBalancerRandomSteeringArrayOutput `pulumi:"randomSteerings"`
// A set containing mappings of region codes to a list of pool IDs (ordered by their failover priority) for the given region.
RegionPools LoadBalancerRegionPoolArrayOutput `pulumi:"regionPools"`
// A list of rules for this load balancer to execute.
Rules LoadBalancerRuleArrayOutput `pulumi:"rules"`
// Configure attributes for session affinity.
SessionAffinity pulumi.StringPtrOutput `pulumi:"sessionAffinity"`
// Configure attributes for session affinity. Note that the property `drainDuration` is not currently supported as a rule override.
SessionAffinityAttributes LoadBalancerSessionAffinityAttributeArrayOutput `pulumi:"sessionAffinityAttributes"`
// Time, in seconds, until this load balancer's session affinity cookie expires after being created. This parameter is ignored unless a supported session affinity policy is set. The current default of `82800` (23 hours) will be used unless `sessionAffinityTtl` is explicitly set. Once the expiry time has been reached, subsequent requests may get sent to a different origin server. Valid values are between `1800` and `604800`.
SessionAffinityTtl pulumi.IntPtrOutput `pulumi:"sessionAffinityTtl"`
// The method the load balancer uses to determine the route to your origin. Value `off` uses `defaultPoolIds`. Value `geo` uses `popPools`/`countryPools`/`regionPools`. For non-proxied requests, the `country` for `countryPools` is determined by `locationStrategy`. Value `random` selects a pool randomly. Value `dynamicLatency` uses round trip time to select the closest pool in `defaultPoolIds` (requires pool health checks). Value `proximity` uses the pools' latitude and longitude to select the closest pool using the Cloudflare PoP location for proxied requests or the location determined by `locationStrategy` for non-proxied requests. Value `leastOutstandingRequests` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of outstanding requests. Pools with more pending requests are weighted proportionately less relative to others. Value `leastConnections` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of open connections. Pools with more open connections are weighted proportionately less relative to others. Supported for HTTP/1 and HTTP/2 connections. Value `""` maps to `geo` if you use `popPools`/`countryPools`/`regionPools` otherwise `off`. Available values: `off`, `geo`, `dynamicLatency`, `random`, `proximity`, `leastOutstandingRequests`, `leastConnections`, `""` Defaults to `""`.
SteeringPolicy pulumi.StringOutput `pulumi:"steeringPolicy"`
// Time to live (TTL) of the DNS entry for the IP address returned by this load balancer. This cannot be set for proxied load balancers. Defaults to `30`.
Ttl pulumi.IntOutput `pulumi:"ttl"`
// The zone ID to add the load balancer to. **Modifying this attribute will force creation of a new resource.**
ZoneId pulumi.StringOutput `pulumi:"zoneId"`
}
// NewLoadBalancer registers a new resource with the given unique name, arguments, and options.
func NewLoadBalancer(ctx *pulumi.Context,
name string, args *LoadBalancerArgs, opts ...pulumi.ResourceOption) (*LoadBalancer, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.DefaultPoolIds == nil {
return nil, errors.New("invalid value for required argument 'DefaultPoolIds'")
}
if args.FallbackPoolId == nil {
return nil, errors.New("invalid value for required argument 'FallbackPoolId'")
}
if args.Name == nil {
return nil, errors.New("invalid value for required argument 'Name'")
}
if args.ZoneId == nil {
return nil, errors.New("invalid value for required argument 'ZoneId'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource LoadBalancer
err := ctx.RegisterResource("cloudflare:index/loadBalancer:LoadBalancer", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetLoadBalancer gets an existing LoadBalancer 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 GetLoadBalancer(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *LoadBalancerState, opts ...pulumi.ResourceOption) (*LoadBalancer, error) {
var resource LoadBalancer
err := ctx.ReadResource("cloudflare:index/loadBalancer:LoadBalancer", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering LoadBalancer resources.
type loadBalancerState struct {
// Controls features that modify the routing of requests to pools and origins in response to dynamic conditions, such as during the interval between active health monitoring requests.
AdaptiveRoutings []LoadBalancerAdaptiveRouting `pulumi:"adaptiveRoutings"`
// A set containing mappings of country codes to a list of pool IDs (ordered by their failover priority) for the given country.
CountryPools []LoadBalancerCountryPool `pulumi:"countryPools"`
// The RFC3339 timestamp of when the load balancer was created.
CreatedOn *string `pulumi:"createdOn"`
// A list of pool IDs ordered by their failover priority. Used whenever `popPools`/`countryPools`/`regionPools` are not defined.
DefaultPoolIds []string `pulumi:"defaultPoolIds"`
// Free text description.
Description *string `pulumi:"description"`
// Enable or disable the load balancer. Defaults to `true`.
Enabled *bool `pulumi:"enabled"`
// The pool ID to use when all other pools are detected as unhealthy.
FallbackPoolId *string `pulumi:"fallbackPoolId"`
// Controls location-based steering for non-proxied requests.
LocationStrategies []LoadBalancerLocationStrategy `pulumi:"locationStrategies"`
// The RFC3339 timestamp of when the load balancer was last modified.
ModifiedOn *string `pulumi:"modifiedOn"`
// Human readable name for this rule.
Name *string `pulumi:"name"`
// A set containing mappings of Cloudflare Point-of-Presence (PoP) identifiers to a list of pool IDs (ordered by their failover priority) for the PoP (datacenter). This feature is only available to enterprise customers.
PopPools []LoadBalancerPopPool `pulumi:"popPools"`
// Whether the hostname gets Cloudflare's origin protection. Defaults to `false`. Conflicts with `ttl`.
Proxied *bool `pulumi:"proxied"`
// Configures pool weights. When `steering_policy="random"`, a random pool is selected with probability proportional to pool weights. When `steering_policy="leastOutstandingRequests"`, pool weights are used to scale each pool's outstanding requests. When `steering_policy="leastConnections"`, pool weights are used to scale each pool's open connections.
RandomSteerings []LoadBalancerRandomSteering `pulumi:"randomSteerings"`
// A set containing mappings of region codes to a list of pool IDs (ordered by their failover priority) for the given region.
RegionPools []LoadBalancerRegionPool `pulumi:"regionPools"`
// A list of rules for this load balancer to execute.
Rules []LoadBalancerRule `pulumi:"rules"`
// Configure attributes for session affinity.
SessionAffinity *string `pulumi:"sessionAffinity"`
// Configure attributes for session affinity. Note that the property `drainDuration` is not currently supported as a rule override.
SessionAffinityAttributes []LoadBalancerSessionAffinityAttribute `pulumi:"sessionAffinityAttributes"`
// Time, in seconds, until this load balancer's session affinity cookie expires after being created. This parameter is ignored unless a supported session affinity policy is set. The current default of `82800` (23 hours) will be used unless `sessionAffinityTtl` is explicitly set. Once the expiry time has been reached, subsequent requests may get sent to a different origin server. Valid values are between `1800` and `604800`.
SessionAffinityTtl *int `pulumi:"sessionAffinityTtl"`
// The method the load balancer uses to determine the route to your origin. Value `off` uses `defaultPoolIds`. Value `geo` uses `popPools`/`countryPools`/`regionPools`. For non-proxied requests, the `country` for `countryPools` is determined by `locationStrategy`. Value `random` selects a pool randomly. Value `dynamicLatency` uses round trip time to select the closest pool in `defaultPoolIds` (requires pool health checks). Value `proximity` uses the pools' latitude and longitude to select the closest pool using the Cloudflare PoP location for proxied requests or the location determined by `locationStrategy` for non-proxied requests. Value `leastOutstandingRequests` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of outstanding requests. Pools with more pending requests are weighted proportionately less relative to others. Value `leastConnections` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of open connections. Pools with more open connections are weighted proportionately less relative to others. Supported for HTTP/1 and HTTP/2 connections. Value `""` maps to `geo` if you use `popPools`/`countryPools`/`regionPools` otherwise `off`. Available values: `off`, `geo`, `dynamicLatency`, `random`, `proximity`, `leastOutstandingRequests`, `leastConnections`, `""` Defaults to `""`.
SteeringPolicy *string `pulumi:"steeringPolicy"`
// Time to live (TTL) of the DNS entry for the IP address returned by this load balancer. This cannot be set for proxied load balancers. Defaults to `30`.
Ttl *int `pulumi:"ttl"`
// The zone ID to add the load balancer to. **Modifying this attribute will force creation of a new resource.**
ZoneId *string `pulumi:"zoneId"`
}
type LoadBalancerState struct {
// Controls features that modify the routing of requests to pools and origins in response to dynamic conditions, such as during the interval between active health monitoring requests.
AdaptiveRoutings LoadBalancerAdaptiveRoutingArrayInput
// A set containing mappings of country codes to a list of pool IDs (ordered by their failover priority) for the given country.
CountryPools LoadBalancerCountryPoolArrayInput
// The RFC3339 timestamp of when the load balancer was created.
CreatedOn pulumi.StringPtrInput
// A list of pool IDs ordered by their failover priority. Used whenever `popPools`/`countryPools`/`regionPools` are not defined.
DefaultPoolIds pulumi.StringArrayInput
// Free text description.
Description pulumi.StringPtrInput
// Enable or disable the load balancer. Defaults to `true`.
Enabled pulumi.BoolPtrInput
// The pool ID to use when all other pools are detected as unhealthy.
FallbackPoolId pulumi.StringPtrInput
// Controls location-based steering for non-proxied requests.
LocationStrategies LoadBalancerLocationStrategyArrayInput
// The RFC3339 timestamp of when the load balancer was last modified.
ModifiedOn pulumi.StringPtrInput
// Human readable name for this rule.
Name pulumi.StringPtrInput
// A set containing mappings of Cloudflare Point-of-Presence (PoP) identifiers to a list of pool IDs (ordered by their failover priority) for the PoP (datacenter). This feature is only available to enterprise customers.
PopPools LoadBalancerPopPoolArrayInput
// Whether the hostname gets Cloudflare's origin protection. Defaults to `false`. Conflicts with `ttl`.
Proxied pulumi.BoolPtrInput
// Configures pool weights. When `steering_policy="random"`, a random pool is selected with probability proportional to pool weights. When `steering_policy="leastOutstandingRequests"`, pool weights are used to scale each pool's outstanding requests. When `steering_policy="leastConnections"`, pool weights are used to scale each pool's open connections.
RandomSteerings LoadBalancerRandomSteeringArrayInput
// A set containing mappings of region codes to a list of pool IDs (ordered by their failover priority) for the given region.
RegionPools LoadBalancerRegionPoolArrayInput
// A list of rules for this load balancer to execute.
Rules LoadBalancerRuleArrayInput
// Configure attributes for session affinity.
SessionAffinity pulumi.StringPtrInput
// Configure attributes for session affinity. Note that the property `drainDuration` is not currently supported as a rule override.
SessionAffinityAttributes LoadBalancerSessionAffinityAttributeArrayInput
// Time, in seconds, until this load balancer's session affinity cookie expires after being created. This parameter is ignored unless a supported session affinity policy is set. The current default of `82800` (23 hours) will be used unless `sessionAffinityTtl` is explicitly set. Once the expiry time has been reached, subsequent requests may get sent to a different origin server. Valid values are between `1800` and `604800`.
SessionAffinityTtl pulumi.IntPtrInput
// The method the load balancer uses to determine the route to your origin. Value `off` uses `defaultPoolIds`. Value `geo` uses `popPools`/`countryPools`/`regionPools`. For non-proxied requests, the `country` for `countryPools` is determined by `locationStrategy`. Value `random` selects a pool randomly. Value `dynamicLatency` uses round trip time to select the closest pool in `defaultPoolIds` (requires pool health checks). Value `proximity` uses the pools' latitude and longitude to select the closest pool using the Cloudflare PoP location for proxied requests or the location determined by `locationStrategy` for non-proxied requests. Value `leastOutstandingRequests` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of outstanding requests. Pools with more pending requests are weighted proportionately less relative to others. Value `leastConnections` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of open connections. Pools with more open connections are weighted proportionately less relative to others. Supported for HTTP/1 and HTTP/2 connections. Value `""` maps to `geo` if you use `popPools`/`countryPools`/`regionPools` otherwise `off`. Available values: `off`, `geo`, `dynamicLatency`, `random`, `proximity`, `leastOutstandingRequests`, `leastConnections`, `""` Defaults to `""`.
SteeringPolicy pulumi.StringPtrInput
// Time to live (TTL) of the DNS entry for the IP address returned by this load balancer. This cannot be set for proxied load balancers. Defaults to `30`.
Ttl pulumi.IntPtrInput
// The zone ID to add the load balancer to. **Modifying this attribute will force creation of a new resource.**
ZoneId pulumi.StringPtrInput
}
func (LoadBalancerState) ElementType() reflect.Type {
return reflect.TypeOf((*loadBalancerState)(nil)).Elem()
}
type loadBalancerArgs struct {
// Controls features that modify the routing of requests to pools and origins in response to dynamic conditions, such as during the interval between active health monitoring requests.
AdaptiveRoutings []LoadBalancerAdaptiveRouting `pulumi:"adaptiveRoutings"`
// A set containing mappings of country codes to a list of pool IDs (ordered by their failover priority) for the given country.
CountryPools []LoadBalancerCountryPool `pulumi:"countryPools"`
// A list of pool IDs ordered by their failover priority. Used whenever `popPools`/`countryPools`/`regionPools` are not defined.
DefaultPoolIds []string `pulumi:"defaultPoolIds"`
// Free text description.
Description *string `pulumi:"description"`
// Enable or disable the load balancer. Defaults to `true`.
Enabled *bool `pulumi:"enabled"`
// The pool ID to use when all other pools are detected as unhealthy.
FallbackPoolId string `pulumi:"fallbackPoolId"`
// Controls location-based steering for non-proxied requests.
LocationStrategies []LoadBalancerLocationStrategy `pulumi:"locationStrategies"`
// Human readable name for this rule.
Name string `pulumi:"name"`
// A set containing mappings of Cloudflare Point-of-Presence (PoP) identifiers to a list of pool IDs (ordered by their failover priority) for the PoP (datacenter). This feature is only available to enterprise customers.
PopPools []LoadBalancerPopPool `pulumi:"popPools"`
// Whether the hostname gets Cloudflare's origin protection. Defaults to `false`. Conflicts with `ttl`.
Proxied *bool `pulumi:"proxied"`
// Configures pool weights. When `steering_policy="random"`, a random pool is selected with probability proportional to pool weights. When `steering_policy="leastOutstandingRequests"`, pool weights are used to scale each pool's outstanding requests. When `steering_policy="leastConnections"`, pool weights are used to scale each pool's open connections.
RandomSteerings []LoadBalancerRandomSteering `pulumi:"randomSteerings"`
// A set containing mappings of region codes to a list of pool IDs (ordered by their failover priority) for the given region.
RegionPools []LoadBalancerRegionPool `pulumi:"regionPools"`
// A list of rules for this load balancer to execute.
Rules []LoadBalancerRule `pulumi:"rules"`
// Configure attributes for session affinity.
SessionAffinity *string `pulumi:"sessionAffinity"`
// Configure attributes for session affinity. Note that the property `drainDuration` is not currently supported as a rule override.
SessionAffinityAttributes []LoadBalancerSessionAffinityAttribute `pulumi:"sessionAffinityAttributes"`
// Time, in seconds, until this load balancer's session affinity cookie expires after being created. This parameter is ignored unless a supported session affinity policy is set. The current default of `82800` (23 hours) will be used unless `sessionAffinityTtl` is explicitly set. Once the expiry time has been reached, subsequent requests may get sent to a different origin server. Valid values are between `1800` and `604800`.
SessionAffinityTtl *int `pulumi:"sessionAffinityTtl"`
// The method the load balancer uses to determine the route to your origin. Value `off` uses `defaultPoolIds`. Value `geo` uses `popPools`/`countryPools`/`regionPools`. For non-proxied requests, the `country` for `countryPools` is determined by `locationStrategy`. Value `random` selects a pool randomly. Value `dynamicLatency` uses round trip time to select the closest pool in `defaultPoolIds` (requires pool health checks). Value `proximity` uses the pools' latitude and longitude to select the closest pool using the Cloudflare PoP location for proxied requests or the location determined by `locationStrategy` for non-proxied requests. Value `leastOutstandingRequests` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of outstanding requests. Pools with more pending requests are weighted proportionately less relative to others. Value `leastConnections` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of open connections. Pools with more open connections are weighted proportionately less relative to others. Supported for HTTP/1 and HTTP/2 connections. Value `""` maps to `geo` if you use `popPools`/`countryPools`/`regionPools` otherwise `off`. Available values: `off`, `geo`, `dynamicLatency`, `random`, `proximity`, `leastOutstandingRequests`, `leastConnections`, `""` Defaults to `""`.
SteeringPolicy *string `pulumi:"steeringPolicy"`
// Time to live (TTL) of the DNS entry for the IP address returned by this load balancer. This cannot be set for proxied load balancers. Defaults to `30`.
Ttl *int `pulumi:"ttl"`
// The zone ID to add the load balancer to. **Modifying this attribute will force creation of a new resource.**
ZoneId string `pulumi:"zoneId"`
}
// The set of arguments for constructing a LoadBalancer resource.
type LoadBalancerArgs struct {
// Controls features that modify the routing of requests to pools and origins in response to dynamic conditions, such as during the interval between active health monitoring requests.
AdaptiveRoutings LoadBalancerAdaptiveRoutingArrayInput
// A set containing mappings of country codes to a list of pool IDs (ordered by their failover priority) for the given country.
CountryPools LoadBalancerCountryPoolArrayInput
// A list of pool IDs ordered by their failover priority. Used whenever `popPools`/`countryPools`/`regionPools` are not defined.
DefaultPoolIds pulumi.StringArrayInput
// Free text description.
Description pulumi.StringPtrInput
// Enable or disable the load balancer. Defaults to `true`.
Enabled pulumi.BoolPtrInput
// The pool ID to use when all other pools are detected as unhealthy.
FallbackPoolId pulumi.StringInput
// Controls location-based steering for non-proxied requests.
LocationStrategies LoadBalancerLocationStrategyArrayInput
// Human readable name for this rule.
Name pulumi.StringInput
// A set containing mappings of Cloudflare Point-of-Presence (PoP) identifiers to a list of pool IDs (ordered by their failover priority) for the PoP (datacenter). This feature is only available to enterprise customers.
PopPools LoadBalancerPopPoolArrayInput
// Whether the hostname gets Cloudflare's origin protection. Defaults to `false`. Conflicts with `ttl`.
Proxied pulumi.BoolPtrInput
// Configures pool weights. When `steering_policy="random"`, a random pool is selected with probability proportional to pool weights. When `steering_policy="leastOutstandingRequests"`, pool weights are used to scale each pool's outstanding requests. When `steering_policy="leastConnections"`, pool weights are used to scale each pool's open connections.
RandomSteerings LoadBalancerRandomSteeringArrayInput
// A set containing mappings of region codes to a list of pool IDs (ordered by their failover priority) for the given region.
RegionPools LoadBalancerRegionPoolArrayInput
// A list of rules for this load balancer to execute.
Rules LoadBalancerRuleArrayInput
// Configure attributes for session affinity.
SessionAffinity pulumi.StringPtrInput
// Configure attributes for session affinity. Note that the property `drainDuration` is not currently supported as a rule override.
SessionAffinityAttributes LoadBalancerSessionAffinityAttributeArrayInput
// Time, in seconds, until this load balancer's session affinity cookie expires after being created. This parameter is ignored unless a supported session affinity policy is set. The current default of `82800` (23 hours) will be used unless `sessionAffinityTtl` is explicitly set. Once the expiry time has been reached, subsequent requests may get sent to a different origin server. Valid values are between `1800` and `604800`.
SessionAffinityTtl pulumi.IntPtrInput
// The method the load balancer uses to determine the route to your origin. Value `off` uses `defaultPoolIds`. Value `geo` uses `popPools`/`countryPools`/`regionPools`. For non-proxied requests, the `country` for `countryPools` is determined by `locationStrategy`. Value `random` selects a pool randomly. Value `dynamicLatency` uses round trip time to select the closest pool in `defaultPoolIds` (requires pool health checks). Value `proximity` uses the pools' latitude and longitude to select the closest pool using the Cloudflare PoP location for proxied requests or the location determined by `locationStrategy` for non-proxied requests. Value `leastOutstandingRequests` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of outstanding requests. Pools with more pending requests are weighted proportionately less relative to others. Value `leastConnections` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of open connections. Pools with more open connections are weighted proportionately less relative to others. Supported for HTTP/1 and HTTP/2 connections. Value `""` maps to `geo` if you use `popPools`/`countryPools`/`regionPools` otherwise `off`. Available values: `off`, `geo`, `dynamicLatency`, `random`, `proximity`, `leastOutstandingRequests`, `leastConnections`, `""` Defaults to `""`.
SteeringPolicy pulumi.StringPtrInput
// Time to live (TTL) of the DNS entry for the IP address returned by this load balancer. This cannot be set for proxied load balancers. Defaults to `30`.
Ttl pulumi.IntPtrInput
// The zone ID to add the load balancer to. **Modifying this attribute will force creation of a new resource.**
ZoneId pulumi.StringInput
}
func (LoadBalancerArgs) ElementType() reflect.Type {
return reflect.TypeOf((*loadBalancerArgs)(nil)).Elem()
}
type LoadBalancerInput interface {
pulumi.Input
ToLoadBalancerOutput() LoadBalancerOutput
ToLoadBalancerOutputWithContext(ctx context.Context) LoadBalancerOutput
}
func (*LoadBalancer) ElementType() reflect.Type {
return reflect.TypeOf((**LoadBalancer)(nil)).Elem()
}
func (i *LoadBalancer) ToLoadBalancerOutput() LoadBalancerOutput {
return i.ToLoadBalancerOutputWithContext(context.Background())
}
func (i *LoadBalancer) ToLoadBalancerOutputWithContext(ctx context.Context) LoadBalancerOutput {
return pulumi.ToOutputWithContext(ctx, i).(LoadBalancerOutput)
}
// LoadBalancerArrayInput is an input type that accepts LoadBalancerArray and LoadBalancerArrayOutput values.
// You can construct a concrete instance of `LoadBalancerArrayInput` via:
//
// LoadBalancerArray{ LoadBalancerArgs{...} }
type LoadBalancerArrayInput interface {
pulumi.Input
ToLoadBalancerArrayOutput() LoadBalancerArrayOutput
ToLoadBalancerArrayOutputWithContext(context.Context) LoadBalancerArrayOutput
}
type LoadBalancerArray []LoadBalancerInput
func (LoadBalancerArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*LoadBalancer)(nil)).Elem()
}
func (i LoadBalancerArray) ToLoadBalancerArrayOutput() LoadBalancerArrayOutput {
return i.ToLoadBalancerArrayOutputWithContext(context.Background())
}
func (i LoadBalancerArray) ToLoadBalancerArrayOutputWithContext(ctx context.Context) LoadBalancerArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(LoadBalancerArrayOutput)
}
// LoadBalancerMapInput is an input type that accepts LoadBalancerMap and LoadBalancerMapOutput values.
// You can construct a concrete instance of `LoadBalancerMapInput` via:
//
// LoadBalancerMap{ "key": LoadBalancerArgs{...} }
type LoadBalancerMapInput interface {
pulumi.Input
ToLoadBalancerMapOutput() LoadBalancerMapOutput
ToLoadBalancerMapOutputWithContext(context.Context) LoadBalancerMapOutput
}
type LoadBalancerMap map[string]LoadBalancerInput
func (LoadBalancerMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*LoadBalancer)(nil)).Elem()
}
func (i LoadBalancerMap) ToLoadBalancerMapOutput() LoadBalancerMapOutput {
return i.ToLoadBalancerMapOutputWithContext(context.Background())
}
func (i LoadBalancerMap) ToLoadBalancerMapOutputWithContext(ctx context.Context) LoadBalancerMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(LoadBalancerMapOutput)
}
type LoadBalancerOutput struct{ *pulumi.OutputState }
func (LoadBalancerOutput) ElementType() reflect.Type {
return reflect.TypeOf((**LoadBalancer)(nil)).Elem()
}
func (o LoadBalancerOutput) ToLoadBalancerOutput() LoadBalancerOutput {
return o
}
func (o LoadBalancerOutput) ToLoadBalancerOutputWithContext(ctx context.Context) LoadBalancerOutput {
return o
}
// Controls features that modify the routing of requests to pools and origins in response to dynamic conditions, such as during the interval between active health monitoring requests.
func (o LoadBalancerOutput) AdaptiveRoutings() LoadBalancerAdaptiveRoutingArrayOutput {
return o.ApplyT(func(v *LoadBalancer) LoadBalancerAdaptiveRoutingArrayOutput { return v.AdaptiveRoutings }).(LoadBalancerAdaptiveRoutingArrayOutput)
}
// A set containing mappings of country codes to a list of pool IDs (ordered by their failover priority) for the given country.
func (o LoadBalancerOutput) CountryPools() LoadBalancerCountryPoolArrayOutput {
return o.ApplyT(func(v *LoadBalancer) LoadBalancerCountryPoolArrayOutput { return v.CountryPools }).(LoadBalancerCountryPoolArrayOutput)
}
// The RFC3339 timestamp of when the load balancer was created.
func (o LoadBalancerOutput) CreatedOn() pulumi.StringOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.StringOutput { return v.CreatedOn }).(pulumi.StringOutput)
}
// A list of pool IDs ordered by their failover priority. Used whenever `popPools`/`countryPools`/`regionPools` are not defined.
func (o LoadBalancerOutput) DefaultPoolIds() pulumi.StringArrayOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.StringArrayOutput { return v.DefaultPoolIds }).(pulumi.StringArrayOutput)
}
// Free text description.
func (o LoadBalancerOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// Enable or disable the load balancer. Defaults to `true`.
func (o LoadBalancerOutput) Enabled() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.BoolPtrOutput { return v.Enabled }).(pulumi.BoolPtrOutput)
}
// The pool ID to use when all other pools are detected as unhealthy.
func (o LoadBalancerOutput) FallbackPoolId() pulumi.StringOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.StringOutput { return v.FallbackPoolId }).(pulumi.StringOutput)
}
// Controls location-based steering for non-proxied requests.
func (o LoadBalancerOutput) LocationStrategies() LoadBalancerLocationStrategyArrayOutput {
return o.ApplyT(func(v *LoadBalancer) LoadBalancerLocationStrategyArrayOutput { return v.LocationStrategies }).(LoadBalancerLocationStrategyArrayOutput)
}
// The RFC3339 timestamp of when the load balancer was last modified.
func (o LoadBalancerOutput) ModifiedOn() pulumi.StringOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.StringOutput { return v.ModifiedOn }).(pulumi.StringOutput)
}
// Human readable name for this rule.
func (o LoadBalancerOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// A set containing mappings of Cloudflare Point-of-Presence (PoP) identifiers to a list of pool IDs (ordered by their failover priority) for the PoP (datacenter). This feature is only available to enterprise customers.
func (o LoadBalancerOutput) PopPools() LoadBalancerPopPoolArrayOutput {
return o.ApplyT(func(v *LoadBalancer) LoadBalancerPopPoolArrayOutput { return v.PopPools }).(LoadBalancerPopPoolArrayOutput)
}
// Whether the hostname gets Cloudflare's origin protection. Defaults to `false`. Conflicts with `ttl`.
func (o LoadBalancerOutput) Proxied() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.BoolPtrOutput { return v.Proxied }).(pulumi.BoolPtrOutput)
}
// Configures pool weights. When `steering_policy="random"`, a random pool is selected with probability proportional to pool weights. When `steering_policy="leastOutstandingRequests"`, pool weights are used to scale each pool's outstanding requests. When `steering_policy="leastConnections"`, pool weights are used to scale each pool's open connections.
func (o LoadBalancerOutput) RandomSteerings() LoadBalancerRandomSteeringArrayOutput {
return o.ApplyT(func(v *LoadBalancer) LoadBalancerRandomSteeringArrayOutput { return v.RandomSteerings }).(LoadBalancerRandomSteeringArrayOutput)
}
// A set containing mappings of region codes to a list of pool IDs (ordered by their failover priority) for the given region.
func (o LoadBalancerOutput) RegionPools() LoadBalancerRegionPoolArrayOutput {
return o.ApplyT(func(v *LoadBalancer) LoadBalancerRegionPoolArrayOutput { return v.RegionPools }).(LoadBalancerRegionPoolArrayOutput)
}
// A list of rules for this load balancer to execute.
func (o LoadBalancerOutput) Rules() LoadBalancerRuleArrayOutput {
return o.ApplyT(func(v *LoadBalancer) LoadBalancerRuleArrayOutput { return v.Rules }).(LoadBalancerRuleArrayOutput)
}
// Configure attributes for session affinity.
func (o LoadBalancerOutput) SessionAffinity() pulumi.StringPtrOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.StringPtrOutput { return v.SessionAffinity }).(pulumi.StringPtrOutput)
}
// Configure attributes for session affinity. Note that the property `drainDuration` is not currently supported as a rule override.
func (o LoadBalancerOutput) SessionAffinityAttributes() LoadBalancerSessionAffinityAttributeArrayOutput {
return o.ApplyT(func(v *LoadBalancer) LoadBalancerSessionAffinityAttributeArrayOutput {
return v.SessionAffinityAttributes
}).(LoadBalancerSessionAffinityAttributeArrayOutput)
}
// Time, in seconds, until this load balancer's session affinity cookie expires after being created. This parameter is ignored unless a supported session affinity policy is set. The current default of `82800` (23 hours) will be used unless `sessionAffinityTtl` is explicitly set. Once the expiry time has been reached, subsequent requests may get sent to a different origin server. Valid values are between `1800` and `604800`.
func (o LoadBalancerOutput) SessionAffinityTtl() pulumi.IntPtrOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.IntPtrOutput { return v.SessionAffinityTtl }).(pulumi.IntPtrOutput)
}
// The method the load balancer uses to determine the route to your origin. Value `off` uses `defaultPoolIds`. Value `geo` uses `popPools`/`countryPools`/`regionPools`. For non-proxied requests, the `country` for `countryPools` is determined by `locationStrategy`. Value `random` selects a pool randomly. Value `dynamicLatency` uses round trip time to select the closest pool in `defaultPoolIds` (requires pool health checks). Value `proximity` uses the pools' latitude and longitude to select the closest pool using the Cloudflare PoP location for proxied requests or the location determined by `locationStrategy` for non-proxied requests. Value `leastOutstandingRequests` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of outstanding requests. Pools with more pending requests are weighted proportionately less relative to others. Value `leastConnections` selects a pool by taking into consideration `randomSteering` weights, as well as each pool's number of open connections. Pools with more open connections are weighted proportionately less relative to others. Supported for HTTP/1 and HTTP/2 connections. Value `""` maps to `geo` if you use `popPools`/`countryPools`/`regionPools` otherwise `off`. Available values: `off`, `geo`, `dynamicLatency`, `random`, `proximity`, `leastOutstandingRequests`, `leastConnections`, `""` Defaults to `""`.
func (o LoadBalancerOutput) SteeringPolicy() pulumi.StringOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.StringOutput { return v.SteeringPolicy }).(pulumi.StringOutput)
}
// Time to live (TTL) of the DNS entry for the IP address returned by this load balancer. This cannot be set for proxied load balancers. Defaults to `30`.
func (o LoadBalancerOutput) Ttl() pulumi.IntOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.IntOutput { return v.Ttl }).(pulumi.IntOutput)
}
// The zone ID to add the load balancer to. **Modifying this attribute will force creation of a new resource.**
func (o LoadBalancerOutput) ZoneId() pulumi.StringOutput {
return o.ApplyT(func(v *LoadBalancer) pulumi.StringOutput { return v.ZoneId }).(pulumi.StringOutput)
}
type LoadBalancerArrayOutput struct{ *pulumi.OutputState }
func (LoadBalancerArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*LoadBalancer)(nil)).Elem()
}
func (o LoadBalancerArrayOutput) ToLoadBalancerArrayOutput() LoadBalancerArrayOutput {
return o
}
func (o LoadBalancerArrayOutput) ToLoadBalancerArrayOutputWithContext(ctx context.Context) LoadBalancerArrayOutput {
return o
}
func (o LoadBalancerArrayOutput) Index(i pulumi.IntInput) LoadBalancerOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *LoadBalancer {
return vs[0].([]*LoadBalancer)[vs[1].(int)]
}).(LoadBalancerOutput)
}
type LoadBalancerMapOutput struct{ *pulumi.OutputState }
func (LoadBalancerMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*LoadBalancer)(nil)).Elem()
}
func (o LoadBalancerMapOutput) ToLoadBalancerMapOutput() LoadBalancerMapOutput {
return o
}
func (o LoadBalancerMapOutput) ToLoadBalancerMapOutputWithContext(ctx context.Context) LoadBalancerMapOutput {
return o
}
func (o LoadBalancerMapOutput) MapIndex(k pulumi.StringInput) LoadBalancerOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *LoadBalancer {
return vs[0].(map[string]*LoadBalancer)[vs[1].(string)]
}).(LoadBalancerOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*LoadBalancerInput)(nil)).Elem(), &LoadBalancer{})
pulumi.RegisterInputType(reflect.TypeOf((*LoadBalancerArrayInput)(nil)).Elem(), LoadBalancerArray{})
pulumi.RegisterInputType(reflect.TypeOf((*LoadBalancerMapInput)(nil)).Elem(), LoadBalancerMap{})
pulumi.RegisterOutputType(LoadBalancerOutput{})
pulumi.RegisterOutputType(LoadBalancerArrayOutput{})
pulumi.RegisterOutputType(LoadBalancerMapOutput{})
}