Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.cloudflare.kotlin
import com.pulumi.cloudflare.LoadBalancerArgs.builder
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerAdaptiveRoutingArgs
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerAdaptiveRoutingArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerCountryPoolArgs
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerCountryPoolArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerLocationStrategyArgs
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerLocationStrategyArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerPopPoolArgs
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerPopPoolArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerRandomSteeringArgs
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerRandomSteeringArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerRegionPoolArgs
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerRegionPoolArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerRuleArgs
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerRuleArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerSessionAffinityAttributeArgs
import com.pulumi.cloudflare.kotlin.inputs.LoadBalancerSessionAffinityAttributeArgsBuilder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName
/**
* 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
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as cloudflare from "@pulumi/cloudflare";
* const exampleLoadBalancerPool = new cloudflare.LoadBalancerPool("example", {
* name: "example-lb-pool",
* origins: [{
* name: "example-1",
* address: "192.0.2.1",
* enabled: false,
* }],
* });
* // 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.
* const example = new cloudflare.LoadBalancer("example", {
* zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
* name: "example-load-balancer.example.com",
* fallbackPoolId: exampleLoadBalancerPool.id,
* defaultPoolIds: [exampleLoadBalancerPool.id],
* description: "example load balancer using geo-balancing",
* proxied: true,
* steeringPolicy: "geo",
* popPools: [{
* pop: "LAX",
* poolIds: [exampleLoadBalancerPool.id],
* }],
* countryPools: [{
* country: "US",
* poolIds: [exampleLoadBalancerPool.id],
* }],
* regionPools: [{
* region: "WNAM",
* poolIds: [exampleLoadBalancerPool.id],
* }],
* rules: [{
* name: "example rule",
* condition: "http.request.uri.path contains \"testing\"",
* fixedResponse: {
* messageBody: "hello",
* statusCode: 200,
* contentType: "html",
* location: "www.example.com",
* },
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_cloudflare as cloudflare
* example_load_balancer_pool = cloudflare.LoadBalancerPool("example",
* name="example-lb-pool",
* origins=[{
* "name": "example-1",
* "address": "192.0.2.1",
* "enabled": False,
* }])
* # 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.
* example = cloudflare.LoadBalancer("example",
* zone_id="0da42c8d2132a9ddaf714f9e7c920711",
* name="example-load-balancer.example.com",
* fallback_pool_id=example_load_balancer_pool.id,
* default_pool_ids=[example_load_balancer_pool.id],
* description="example load balancer using geo-balancing",
* proxied=True,
* steering_policy="geo",
* pop_pools=[{
* "pop": "LAX",
* "pool_ids": [example_load_balancer_pool.id],
* }],
* country_pools=[{
* "country": "US",
* "pool_ids": [example_load_balancer_pool.id],
* }],
* region_pools=[{
* "region": "WNAM",
* "pool_ids": [example_load_balancer_pool.id],
* }],
* rules=[{
* "name": "example rule",
* "condition": "http.request.uri.path contains \"testing\"",
* "fixed_response": {
* "message_body": "hello",
* "status_code": 200,
* "content_type": "html",
* "location": "www.example.com",
* },
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Cloudflare = Pulumi.Cloudflare;
* return await Deployment.RunAsync(() =>
* {
* var exampleLoadBalancerPool = new Cloudflare.LoadBalancerPool("example", new()
* {
* Name = "example-lb-pool",
* Origins = new[]
* {
* new Cloudflare.Inputs.LoadBalancerPoolOriginArgs
* {
* Name = "example-1",
* Address = "192.0.2.1",
* Enabled = false,
* },
* },
* });
* // 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.
* var example = new Cloudflare.LoadBalancer("example", new()
* {
* ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
* Name = "example-load-balancer.example.com",
* FallbackPoolId = exampleLoadBalancerPool.Id,
* DefaultPoolIds = new[]
* {
* exampleLoadBalancerPool.Id,
* },
* Description = "example load balancer using geo-balancing",
* Proxied = true,
* SteeringPolicy = "geo",
* PopPools = new[]
* {
* new Cloudflare.Inputs.LoadBalancerPopPoolArgs
* {
* Pop = "LAX",
* PoolIds = new[]
* {
* exampleLoadBalancerPool.Id,
* },
* },
* },
* CountryPools = new[]
* {
* new Cloudflare.Inputs.LoadBalancerCountryPoolArgs
* {
* Country = "US",
* PoolIds = new[]
* {
* exampleLoadBalancerPool.Id,
* },
* },
* },
* RegionPools = new[]
* {
* new Cloudflare.Inputs.LoadBalancerRegionPoolArgs
* {
* Region = "WNAM",
* PoolIds = new[]
* {
* exampleLoadBalancerPool.Id,
* },
* },
* },
* Rules = new[]
* {
* new Cloudflare.Inputs.LoadBalancerRuleArgs
* {
* Name = "example rule",
* Condition = "http.request.uri.path contains \"testing\"",
* FixedResponse = new Cloudflare.Inputs.LoadBalancerRuleFixedResponseArgs
* {
* MessageBody = "hello",
* StatusCode = 200,
* ContentType = "html",
* Location = "www.example.com",
* },
* },
* },
* });
* });
* ```
* ```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, "example", &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, "example", &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
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.cloudflare.LoadBalancerPool;
* import com.pulumi.cloudflare.LoadBalancerPoolArgs;
* import com.pulumi.cloudflare.inputs.LoadBalancerPoolOriginArgs;
* import com.pulumi.cloudflare.LoadBalancer;
* import com.pulumi.cloudflare.LoadBalancerArgs;
* import com.pulumi.cloudflare.inputs.LoadBalancerPopPoolArgs;
* import com.pulumi.cloudflare.inputs.LoadBalancerCountryPoolArgs;
* import com.pulumi.cloudflare.inputs.LoadBalancerRegionPoolArgs;
* import com.pulumi.cloudflare.inputs.LoadBalancerRuleArgs;
* import com.pulumi.cloudflare.inputs.LoadBalancerRuleFixedResponseArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var exampleLoadBalancerPool = new LoadBalancerPool("exampleLoadBalancerPool", LoadBalancerPoolArgs.builder()
* .name("example-lb-pool")
* .origins(LoadBalancerPoolOriginArgs.builder()
* .name("example-1")
* .address("192.0.2.1")
* .enabled(false)
* .build())
* .build());
* // 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.
* var example = new LoadBalancer("example", LoadBalancerArgs.builder()
* .zoneId("0da42c8d2132a9ddaf714f9e7c920711")
* .name("example-load-balancer.example.com")
* .fallbackPoolId(exampleLoadBalancerPool.id())
* .defaultPoolIds(exampleLoadBalancerPool.id())
* .description("example load balancer using geo-balancing")
* .proxied(true)
* .steeringPolicy("geo")
* .popPools(LoadBalancerPopPoolArgs.builder()
* .pop("LAX")
* .poolIds(exampleLoadBalancerPool.id())
* .build())
* .countryPools(LoadBalancerCountryPoolArgs.builder()
* .country("US")
* .poolIds(exampleLoadBalancerPool.id())
* .build())
* .regionPools(LoadBalancerRegionPoolArgs.builder()
* .region("WNAM")
* .poolIds(exampleLoadBalancerPool.id())
* .build())
* .rules(LoadBalancerRuleArgs.builder()
* .name("example rule")
* .condition("http.request.uri.path contains \"testing\"")
* .fixedResponse(LoadBalancerRuleFixedResponseArgs.builder()
* .messageBody("hello")
* .statusCode(200)
* .contentType("html")
* .location("www.example.com")
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* # 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.
* example:
* type: cloudflare:LoadBalancer
* properties:
* zoneId: 0da42c8d2132a9ddaf714f9e7c920711
* name: example-load-balancer.example.com
* fallbackPoolId: ${exampleLoadBalancerPool.id}
* defaultPoolIds:
* - ${exampleLoadBalancerPool.id}
* description: example load balancer using geo-balancing
* proxied: true
* steeringPolicy: geo
* popPools:
* - pop: LAX
* poolIds:
* - ${exampleLoadBalancerPool.id}
* countryPools:
* - country: US
* poolIds:
* - ${exampleLoadBalancerPool.id}
* regionPools:
* - region: WNAM
* poolIds:
* - ${exampleLoadBalancerPool.id}
* rules:
* - name: example rule
* condition: http.request.uri.path contains "testing"
* fixedResponse:
* messageBody: hello
* statusCode: 200
* contentType: html
* location: www.example.com
* exampleLoadBalancerPool:
* type: cloudflare:LoadBalancerPool
* name: example
* properties:
* name: example-lb-pool
* origins:
* - name: example-1
* address: 192.0.2.1
* enabled: false
* ```
*
* ## Import
* ```sh
* $ pulumi import cloudflare:index/loadBalancer:LoadBalancer example /
* ```
* @property adaptiveRoutings 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.
* @property countryPools A set containing mappings of country codes to a list of pool IDs (ordered by their failover priority) for the given country.
* @property defaultPoolIds A list of pool IDs ordered by their failover priority. Used whenever `pop_pools`/`country_pools`/`region_pools` are not defined.
* @property description Free text description.
* @property enabled Enable or disable the load balancer. Defaults to `true`.
* @property fallbackPoolId The pool ID to use when all other pools are detected as unhealthy.
* @property locationStrategies Controls location-based steering for non-proxied requests.
* @property name The DNS hostname to associate with your load balancer. If this hostname already exists as a DNS record in Cloudflare's DNS, the load balancer will take precedence and the DNS record will not be used.
* @property popPools 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.
* @property proxied Whether the hostname gets Cloudflare's origin protection. Defaults to `false`. Conflicts with `ttl`.
* @property randomSteerings Configures pool weights. When `steering_policy="random"`, a random pool is selected with probability proportional to pool weights. When `steering_policy="least_outstanding_requests"`, pool weights are used to scale each pool's outstanding requests. When `steering_policy="least_connections"`, pool weights are used to scale each pool's open connections.
* @property regionPools A set containing mappings of region codes to a list of pool IDs (ordered by their failover priority) for the given region.
* @property rules A list of rules for this load balancer to execute.
* @property sessionAffinity Specifies the type of session affinity the load balancer should use unless specified as `none` or `""` (default). With value `cookie`, on the first request to a proxied load balancer, a cookie is generated, encoding information of which origin the request will be forwarded to. Subsequent requests, by the same client to the same load balancer, will be sent to the origin server the cookie encodes, for the duration of the cookie and as long as the origin server remains healthy. If the cookie has expired or the origin server is unhealthy then a new origin server is calculated and used. Value `ip_cookie` behaves the same as `cookie` except the initial origin selection is stable and based on the client's IP address. Available values: `""`, `none`, `cookie`, `ip_cookie`, `header`. Defaults to `none`.
* @property sessionAffinityAttributes Configure attributes for session affinity.
* @property sessionAffinityTtl 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 `session_affinity_ttl` 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`.
* @property steeringPolicy The method the load balancer uses to determine the route to your origin. Value `off` uses `default_pool_ids`. Value `geo` uses `pop_pools`/`country_pools`/`region_pools`. For non-proxied requests, the `country` for `country_pools` is determined by `location_strategy`. Value `random` selects a pool randomly. Value `dynamic_latency` uses round trip time to select the closest pool in `default_pool_ids` (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 `location_strategy` for non-proxied requests. Value `least_outstanding_requests` selects a pool by taking into consideration `random_steering` weights, as well as each pool's number of outstanding requests. Pools with more pending requests are weighted proportionately less relative to others. Value `least_connections` selects a pool by taking into consideration `random_steering` 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 `pop_pools`/`country_pools`/`region_pools` otherwise `off`. Available values: `off`, `geo`, `dynamic_latency`, `random`, `proximity`, `least_outstanding_requests`, `least_connections`, `""` Defaults to `""`.
* @property ttl 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`. Conflicts with `proxied`.
* @property zoneId The zone ID to add the load balancer to. **Modifying this attribute will force creation of a new resource.**
*/
public data class LoadBalancerArgs(
public val adaptiveRoutings: Output>? = null,
public val countryPools: Output>? = null,
public val defaultPoolIds: Output>? = null,
public val description: Output? = null,
public val enabled: Output? = null,
public val fallbackPoolId: Output? = null,
public val locationStrategies: Output>? = null,
public val name: Output? = null,
public val popPools: Output>? = null,
public val proxied: Output? = null,
public val randomSteerings: Output>? = null,
public val regionPools: Output>? = null,
public val rules: Output>? = null,
public val sessionAffinity: Output? = null,
public val sessionAffinityAttributes: Output>? =
null,
public val sessionAffinityTtl: Output? = null,
public val steeringPolicy: Output? = null,
public val ttl: Output? = null,
public val zoneId: Output? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.cloudflare.LoadBalancerArgs =
com.pulumi.cloudflare.LoadBalancerArgs.builder()
.adaptiveRoutings(
adaptiveRoutings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.countryPools(
countryPools?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.defaultPoolIds(defaultPoolIds?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
.description(description?.applyValue({ args0 -> args0 }))
.enabled(enabled?.applyValue({ args0 -> args0 }))
.fallbackPoolId(fallbackPoolId?.applyValue({ args0 -> args0 }))
.locationStrategies(
locationStrategies?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> args0.toJava() })
})
}),
)
.name(name?.applyValue({ args0 -> args0 }))
.popPools(
popPools?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.proxied(proxied?.applyValue({ args0 -> args0 }))
.randomSteerings(
randomSteerings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.regionPools(
regionPools?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.rules(rules?.applyValue({ args0 -> args0.map({ args0 -> args0.let({ args0 -> args0.toJava() }) }) }))
.sessionAffinity(sessionAffinity?.applyValue({ args0 -> args0 }))
.sessionAffinityAttributes(
sessionAffinityAttributes?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> args0.toJava() })
})
}),
)
.sessionAffinityTtl(sessionAffinityTtl?.applyValue({ args0 -> args0 }))
.steeringPolicy(steeringPolicy?.applyValue({ args0 -> args0 }))
.ttl(ttl?.applyValue({ args0 -> args0 }))
.zoneId(zoneId?.applyValue({ args0 -> args0 })).build()
}
/**
* Builder for [LoadBalancerArgs].
*/
@PulumiTagMarker
public class LoadBalancerArgsBuilder internal constructor() {
private var adaptiveRoutings: Output>? = null
private var countryPools: Output>? = null
private var defaultPoolIds: Output>? = null
private var description: Output? = null
private var enabled: Output? = null
private var fallbackPoolId: Output? = null
private var locationStrategies: Output>? = null
private var name: Output? = null
private var popPools: Output>? = null
private var proxied: Output? = null
private var randomSteerings: Output>? = null
private var regionPools: Output>? = null
private var rules: Output>? = null
private var sessionAffinity: Output? = null
private var sessionAffinityAttributes: Output>? =
null
private var sessionAffinityTtl: Output? = null
private var steeringPolicy: Output? = null
private var ttl: Output? = null
private var zoneId: Output? = null
/**
* @param value 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.
*/
@JvmName("xbxmqyujpcfrngjm")
public suspend fun adaptiveRoutings(`value`: Output>) {
this.adaptiveRoutings = value
}
@JvmName("lcclkdpbfjfevfse")
public suspend fun adaptiveRoutings(vararg values: Output) {
this.adaptiveRoutings = Output.all(values.asList())
}
/**
* @param values 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.
*/
@JvmName("hnnpjunyqxlfffow")
public suspend fun adaptiveRoutings(values: List