Load Balancer Args
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
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());
var exampleLoadBalancer = new LoadBalancer("exampleLoadBalancer", 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());
}
}
Import
$ pulumi import cloudflare:index/loadBalancer:LoadBalancer example <zone_id>/<load_balancer_id>
Constructors
Functions
Properties
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
. Defaults to none
.
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
.
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 ""
maps to geo
if you use pop_pools
/country_pools
/region_pools
otherwise off
. Available values: off
, geo
, dynamic_latency
, random
, proximity
, ""
Defaults to ""
.