com.pulumi.cloudflare.LoadBalancer Maven / Gradle / Ivy
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package com.pulumi.cloudflare;
import com.pulumi.cloudflare.LoadBalancerArgs;
import com.pulumi.cloudflare.Utilities;
import com.pulumi.cloudflare.inputs.LoadBalancerState;
import com.pulumi.cloudflare.outputs.LoadBalancerAdaptiveRouting;
import com.pulumi.cloudflare.outputs.LoadBalancerCountryPool;
import com.pulumi.cloudflare.outputs.LoadBalancerLocationStrategy;
import com.pulumi.cloudflare.outputs.LoadBalancerPopPool;
import com.pulumi.cloudflare.outputs.LoadBalancerRandomSteering;
import com.pulumi.cloudflare.outputs.LoadBalancerRegionPool;
import com.pulumi.cloudflare.outputs.LoadBalancerRule;
import com.pulumi.cloudflare.outputs.LoadBalancerSessionAffinityAttribute;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* 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
* ```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());
*
* 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
*
* ```sh
* $ pulumi import cloudflare:index/loadBalancer:LoadBalancer example <zone_id>/<load_balancer_id>
* ```
*
*/
@ResourceType(type="cloudflare:index/loadBalancer:LoadBalancer")
public class LoadBalancer extends com.pulumi.resources.CustomResource {
/**
* 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.
*
*/
@Export(name="adaptiveRoutings", type=List.class, parameters={LoadBalancerAdaptiveRouting.class})
private Output* @Nullable */ List> adaptiveRoutings;
/**
* @return 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.
*
*/
public Output>> adaptiveRoutings() {
return Codegen.optional(this.adaptiveRoutings);
}
/**
* A set containing mappings of country codes to a list of pool IDs (ordered by their failover priority) for the given country.
*
*/
@Export(name="countryPools", type=List.class, parameters={LoadBalancerCountryPool.class})
private Output> countryPools;
/**
* @return A set containing mappings of country codes to a list of pool IDs (ordered by their failover priority) for the given country.
*
*/
public Output> countryPools() {
return this.countryPools;
}
/**
* The RFC3339 timestamp of when the load balancer was created.
*
*/
@Export(name="createdOn", type=String.class, parameters={})
private Output createdOn;
/**
* @return The RFC3339 timestamp of when the load balancer was created.
*
*/
public Output createdOn() {
return this.createdOn;
}
/**
* A list of pool IDs ordered by their failover priority. Used whenever `pop_pools`/`country_pools`/`region_pools` are not defined.
*
*/
@Export(name="defaultPoolIds", type=List.class, parameters={String.class})
private Output> defaultPoolIds;
/**
* @return A list of pool IDs ordered by their failover priority. Used whenever `pop_pools`/`country_pools`/`region_pools` are not defined.
*
*/
public Output> defaultPoolIds() {
return this.defaultPoolIds;
}
/**
* Free text description.
*
*/
@Export(name="description", type=String.class, parameters={})
private Output* @Nullable */ String> description;
/**
* @return Free text description.
*
*/
public Output> description() {
return Codegen.optional(this.description);
}
/**
* Enable or disable the load balancer. Defaults to `true`.
*
*/
@Export(name="enabled", type=Boolean.class, parameters={})
private Output* @Nullable */ Boolean> enabled;
/**
* @return Enable or disable the load balancer. Defaults to `true`.
*
*/
public Output> enabled() {
return Codegen.optional(this.enabled);
}
/**
* The pool ID to use when all other pools are detected as unhealthy.
*
*/
@Export(name="fallbackPoolId", type=String.class, parameters={})
private Output fallbackPoolId;
/**
* @return The pool ID to use when all other pools are detected as unhealthy.
*
*/
public Output fallbackPoolId() {
return this.fallbackPoolId;
}
/**
* Controls location-based steering for non-proxied requests.
*
*/
@Export(name="locationStrategies", type=List.class, parameters={LoadBalancerLocationStrategy.class})
private Output* @Nullable */ List> locationStrategies;
/**
* @return Controls location-based steering for non-proxied requests.
*
*/
public Output>> locationStrategies() {
return Codegen.optional(this.locationStrategies);
}
/**
* The RFC3339 timestamp of when the load balancer was last modified.
*
*/
@Export(name="modifiedOn", type=String.class, parameters={})
private Output modifiedOn;
/**
* @return The RFC3339 timestamp of when the load balancer was last modified.
*
*/
public Output modifiedOn() {
return this.modifiedOn;
}
/**
* 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.
*
*/
@Export(name="name", type=String.class, parameters={})
private Output name;
/**
* @return 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.
*
*/
public Output name() {
return this.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.
*
*/
@Export(name="popPools", type=List.class, parameters={LoadBalancerPopPool.class})
private Output> popPools;
/**
* @return 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.
*
*/
public Output> popPools() {
return this.popPools;
}
/**
* Whether the hostname gets Cloudflare's origin protection. Defaults to `false`. Conflicts with `ttl`.
*
*/
@Export(name="proxied", type=Boolean.class, parameters={})
private Output* @Nullable */ Boolean> proxied;
/**
* @return Whether the hostname gets Cloudflare's origin protection. Defaults to `false`. Conflicts with `ttl`.
*
*/
public Output> proxied() {
return Codegen.optional(this.proxied);
}
/**
* Configures pool weights for random steering. When the `steering_policy="random"`, a random pool is selected with probability proportional to these pool weights.
*
*/
@Export(name="randomSteerings", type=List.class, parameters={LoadBalancerRandomSteering.class})
private Output* @Nullable */ List> randomSteerings;
/**
* @return Configures pool weights for random steering. When the `steering_policy="random"`, a random pool is selected with probability proportional to these pool weights.
*
*/
public Output>> randomSteerings() {
return Codegen.optional(this.randomSteerings);
}
/**
* A set containing mappings of region codes to a list of pool IDs (ordered by their failover priority) for the given region.
*
*/
@Export(name="regionPools", type=List.class, parameters={LoadBalancerRegionPool.class})
private Output> regionPools;
/**
* @return A set containing mappings of region codes to a list of pool IDs (ordered by their failover priority) for the given region.
*
*/
public Output> regionPools() {
return this.regionPools;
}
/**
* A list of rules for this load balancer to execute.
*
*/
@Export(name="rules", type=List.class, parameters={LoadBalancerRule.class})
private Output* @Nullable */ List> rules;
/**
* @return A list of rules for this load balancer to execute.
*
*/
public Output>> rules() {
return Codegen.optional(this.rules);
}
/**
* 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`.
*
*/
@Export(name="sessionAffinity", type=String.class, parameters={})
private Output* @Nullable */ String> sessionAffinity;
/**
* @return 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`.
*
*/
public Output> sessionAffinity() {
return Codegen.optional(this.sessionAffinity);
}
/**
* Configure cookie attributes for session affinity cookie.
*
*/
@Export(name="sessionAffinityAttributes", type=List.class, parameters={LoadBalancerSessionAffinityAttribute.class})
private Output* @Nullable */ List> sessionAffinityAttributes;
/**
* @return Configure cookie attributes for session affinity cookie.
*
*/
public Output>> sessionAffinityAttributes() {
return Codegen.optional(this.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 `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`.
*
*/
@Export(name="sessionAffinityTtl", type=Integer.class, parameters={})
private Output* @Nullable */ Integer> sessionAffinityTtl;
/**
* @return 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`.
*
*/
public Output> sessionAffinityTtl() {
return Codegen.optional(this.sessionAffinityTtl);
}
/**
* 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 `""`.
*
*/
@Export(name="steeringPolicy", type=String.class, parameters={})
private Output steeringPolicy;
/**
* @return 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 `""`.
*
*/
public Output steeringPolicy() {
return this.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`. Conflicts with `proxied`.
*
*/
@Export(name="ttl", type=Integer.class, parameters={})
private Output ttl;
/**
* @return 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`.
*
*/
public Output ttl() {
return this.ttl;
}
/**
* The zone ID to add the load balancer to. **Modifying this attribute will force creation of a new resource.**
*
*/
@Export(name="zoneId", type=String.class, parameters={})
private Output zoneId;
/**
* @return The zone ID to add the load balancer to. **Modifying this attribute will force creation of a new resource.**
*
*/
public Output zoneId() {
return this.zoneId;
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public LoadBalancer(String name) {
this(name, LoadBalancerArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public LoadBalancer(String name, LoadBalancerArgs args) {
this(name, args, null);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
* @param options A bag of options that control this resource's behavior.
*/
public LoadBalancer(String name, LoadBalancerArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("cloudflare:index/loadBalancer:LoadBalancer", name, args == null ? LoadBalancerArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
}
private LoadBalancer(String name, Output id, @Nullable LoadBalancerState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("cloudflare:index/loadBalancer:LoadBalancer", name, state, makeResourceOptions(options, id));
}
private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) {
var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
.version(Utilities.getVersion())
.build();
return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
}
/**
* Get an existing Host resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state
* @param options Optional settings to control the behavior of the CustomResource.
*/
public static LoadBalancer get(String name, Output id, @Nullable LoadBalancerState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new LoadBalancer(name, id, state, options);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy