RuleArgs

data class RuleArgs(val cookie: Output<String>? = null, val cookieTimeout: Output<Int>? = null, val deleteProtectionValidation: Output<Boolean>? = null, val domain: Output<String>? = null, val frontendPort: Output<Int>? = null, val healthCheck: Output<String>? = null, val healthCheckConnectPort: Output<Int>? = null, val healthCheckDomain: Output<String>? = null, val healthCheckHttpCode: Output<String>? = null, val healthCheckInterval: Output<Int>? = null, val healthCheckTimeout: Output<Int>? = null, val healthCheckUri: Output<String>? = null, val healthyThreshold: Output<Int>? = null, val listenerSync: Output<String>? = null, val loadBalancerId: Output<String>? = null, val name: Output<String>? = null, val scheduler: Output<String>? = null, val serverGroupId: Output<String>? = null, val stickySession: Output<String>? = null, val stickySessionType: Output<String>? = null, val unhealthyThreshold: Output<Int>? = null, val url: Output<String>? = null) : ConvertibleToJava<RuleArgs>

A forwarding rule is configured in HTTP/HTTPS listener and it used to listen a list of backend servers which in one specified virtual backend server group. You can add forwarding rules to a listener to forward requests based on the domain names or the URL in the request.

NOTE: One virtual backend server group can be attached in multiple forwarding rules. NOTE: At least one "Domain" or "Url" must be specified when creating a new rule. NOTE: Having the same 'Domain' and 'Url' rule can not be created repeatedly in the one listener. NOTE: Rule only be created in the HTTP or HTTPS listener. NOTE: Only rule's virtual server group can be modified.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs;
import com.pulumi.alicloud.ecs.inputs.GetImagesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.ecs.SecurityGroup;
import com.pulumi.alicloud.ecs.SecurityGroupArgs;
import com.pulumi.alicloud.ecs.Instance;
import com.pulumi.alicloud.ecs.InstanceArgs;
import com.pulumi.alicloud.slb.ApplicationLoadBalancer;
import com.pulumi.alicloud.slb.ApplicationLoadBalancerArgs;
import com.pulumi.alicloud.slb.Listener;
import com.pulumi.alicloud.slb.ListenerArgs;
import com.pulumi.alicloud.slb.ServerGroup;
import com.pulumi.alicloud.slb.ServerGroupArgs;
import com.pulumi.alicloud.slb.Rule;
import com.pulumi.alicloud.slb.RuleArgs;
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) {
final var config = ctx.config();
final var slbRuleName = config.get("slbRuleName").orElse("terraform-example");
final var ruleZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableDiskCategory("cloud_efficiency")
.availableResourceCreation("VSwitch")
.build());
final var ruleInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
.availabilityZone(ruleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.cpuCoreCount(1)
.memorySize(2)
.build());
final var ruleImages = EcsFunctions.getImages(GetImagesArgs.builder()
.nameRegex("^ubuntu_18.*64")
.mostRecent(true)
.owners("system")
.build());
var ruleNetwork = new Network("ruleNetwork", NetworkArgs.builder()
.vpcName(slbRuleName)
.cidrBlock("172.16.0.0/16")
.build());
var ruleSwitch = new Switch("ruleSwitch", SwitchArgs.builder()
.vpcId(ruleNetwork.id())
.cidrBlock("172.16.0.0/16")
.zoneId(ruleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.vswitchName(slbRuleName)
.build());
var ruleSecurityGroup = new SecurityGroup("ruleSecurityGroup", SecurityGroupArgs.builder()
.vpcId(ruleNetwork.id())
.build());
var ruleInstance = new Instance("ruleInstance", InstanceArgs.builder()
.imageId(ruleImages.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
.instanceType(ruleInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id()))
.securityGroups(ruleSecurityGroup.stream().map(element -> element.id()).collect(toList()))
.internetChargeType("PayByTraffic")
.internetMaxBandwidthOut("10")
.availabilityZone(ruleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.instanceChargeType("PostPaid")
.systemDiskCategory("cloud_efficiency")
.vswitchId(ruleSwitch.id())
.instanceName(slbRuleName)
.build());
var ruleApplicationLoadBalancer = new ApplicationLoadBalancer("ruleApplicationLoadBalancer", ApplicationLoadBalancerArgs.builder()
.loadBalancerName(slbRuleName)
.vswitchId(ruleSwitch.id())
.instanceChargeType("PayByCLCU")
.build());
var ruleListener = new Listener("ruleListener", ListenerArgs.builder()
.loadBalancerId(ruleApplicationLoadBalancer.id())
.backendPort(22)
.frontendPort(22)
.protocol("http")
.bandwidth(5)
.healthCheckConnectPort("20")
.build());
var ruleServerGroup = new ServerGroup("ruleServerGroup", ServerGroupArgs.builder()
.loadBalancerId(ruleApplicationLoadBalancer.id())
.build());
var ruleRule = new Rule("ruleRule", RuleArgs.builder()
.loadBalancerId(ruleApplicationLoadBalancer.id())
.frontendPort(ruleListener.frontendPort())
.domain("*.aliyun.com")
.url("/image")
.serverGroupId(ruleServerGroup.id())
.cookie("23ffsa")
.cookieTimeout(100)
.healthCheckHttpCode("http_2xx")
.healthCheckInterval(10)
.healthCheckUri("/test")
.healthCheckConnectPort(80)
.healthCheckTimeout(30)
.healthyThreshold(3)
.unhealthyThreshold(5)
.stickySession("on")
.stickySessionType("server")
.listenerSync("off")
.scheduler("rr")
.healthCheckDomain("test")
.healthCheck("on")
.build());
}
}

Import

Load balancer forwarding rule can be imported using the id, e.g.

$ pulumi import alicloud:slb/rule:Rule example rule-abc123456

Constructors

Link copied to clipboard
fun RuleArgs(cookie: Output<String>? = null, cookieTimeout: Output<Int>? = null, deleteProtectionValidation: Output<Boolean>? = null, domain: Output<String>? = null, frontendPort: Output<Int>? = null, healthCheck: Output<String>? = null, healthCheckConnectPort: Output<Int>? = null, healthCheckDomain: Output<String>? = null, healthCheckHttpCode: Output<String>? = null, healthCheckInterval: Output<Int>? = null, healthCheckTimeout: Output<Int>? = null, healthCheckUri: Output<String>? = null, healthyThreshold: Output<Int>? = null, listenerSync: Output<String>? = null, loadBalancerId: Output<String>? = null, name: Output<String>? = null, scheduler: Output<String>? = null, serverGroupId: Output<String>? = null, stickySession: Output<String>? = null, stickySessionType: Output<String>? = null, unhealthyThreshold: Output<Int>? = null, url: Output<String>? = null)

Functions

Link copied to clipboard
open override fun toJava(): RuleArgs

Properties

Link copied to clipboard
val cookie: Output<String>? = null

The cookie configured on the server. It is mandatory when sticky_session is "on" and sticky_session_type is "server". Otherwise, it will be ignored. Valid value:String in line with RFC 2965, with length being 1- 200. It only contains characters such as ASCII codes, English letters and digits instead of the comma, semicolon or spacing, and it cannot start with $.

Link copied to clipboard
val cookieTimeout: Output<Int>? = null

Cookie timeout. It is mandatory when sticky_session is "on" and sticky_session_type is "insert". Otherwise, it will be ignored. Valid value range: 1-86400 in seconds.

Link copied to clipboard
val deleteProtectionValidation: Output<Boolean>? = null

Checking DeleteProtection of SLB instance before deleting. If true, this resource will not be deleted when its SLB instance enabled DeleteProtection. Default to false.

Link copied to clipboard
val domain: Output<String>? = null

Domain name of the forwarding rule. It can contain letters a-z, numbers 0-9, hyphens (-), and periods (.), and wildcard characters. The following two domain name formats are supported:

Link copied to clipboard
val frontendPort: Output<Int>? = null

The listener frontend port which is used to launch the new forwarding rule. Valid range: 1-65535.

Link copied to clipboard
val healthCheck: Output<String>? = null

Whether to enable health check. Valid values areon and off. TCP and UDP listener's HealthCheck is always on, so it will be ignore when launching TCP or UDP listener. This parameter is required and takes effect only when ListenerSync is set to off.

Link copied to clipboard
val healthCheckConnectPort: Output<Int>? = null

Port used for health check. Valid value range: 1-65535. Default to "None" means the backend server port is used.

Link copied to clipboard
val healthCheckDomain: Output<String>? = null

Domain name used for health check. When it used to launch TCP listener, health_check_type must be "http". Its length is limited to 1-80 and only characters such as letters, digits, ‘-‘ and ‘.’ are allowed. When it is not set or empty, Server Load Balancer uses the private network IP address of each backend server as Domain used for health check.

Link copied to clipboard
val healthCheckHttpCode: Output<String>? = null

Regular health check HTTP status code. Multiple codes are segmented by “,”. It is required when health_check is on. Default to http_2xx. Valid values are: http_2xx, http_3xx, http_4xx and http_5xx.

Link copied to clipboard
val healthCheckInterval: Output<Int>? = null

Time interval of health checks. It is required when health_check is on. Valid value range: 1-50 in seconds. Default to 2.

Link copied to clipboard
val healthCheckTimeout: Output<Int>? = null

Maximum timeout of each health check response. It is required when health_check is on. Valid value range: 1-300 in seconds. Default to 5. Note: If health_check_timeout<health_check_interval, its will be replaced by health_check_interval.

Link copied to clipboard
val healthCheckUri: Output<String>? = null

URI used for health check. When it used to launch TCP listener, health_check_type must be "http". Its length is limited to 1-80 and it must start with /. Only characters such as letters, digits, ‘-’, ‘/’, ‘.’, ‘%’, ‘?’, #’ and ‘&’ are allowed.

Link copied to clipboard
val healthyThreshold: Output<Int>? = null

Threshold determining the result of the health check is success. It is required when health_check is on. Valid value range: 1-10 in seconds. Default to 3.

Link copied to clipboard
val listenerSync: Output<String>? = null

Indicates whether a forwarding rule inherits the settings of a health check , session persistence, and scheduling algorithm from a listener. Default to on.

Link copied to clipboard
val loadBalancerId: Output<String>? = null

The Load Balancer ID which is used to launch the new forwarding rule.

Link copied to clipboard
val name: Output<String>? = null

Name of the forwarding rule. Our plugin provides a default name: "tf-slb-rule".

Link copied to clipboard
val scheduler: Output<String>? = null

Scheduling algorithm, Valid values are wrr, rr and wlc. Default to "wrr". This parameter is required and takes effect only when ListenerSync is set to off.

Link copied to clipboard
val serverGroupId: Output<String>? = null

ID of a virtual server group that will be forwarded.

Link copied to clipboard
val stickySession: Output<String>? = null

Whether to enable session persistence, Valid values are on and off. Default to off. This parameter is required and takes effect only when ListenerSync is set to off.

Link copied to clipboard
val stickySessionType: Output<String>? = null

Mode for handling the cookie. If sticky_session is "on", it is mandatory. Otherwise, it will be ignored. Valid values are insert and server. insert means it is inserted from Server Load Balancer; server means the Server Load Balancer learns from the backend server.

Link copied to clipboard
val unhealthyThreshold: Output<Int>? = null

Threshold determining the result of the health check is fail. It is required when health_check is on. Valid value range: 1-10 in seconds. Default to 3.

Link copied to clipboard
val url: Output<String>? = null

Domain of the forwarding rule. It must be 2-80 characters in length. Only letters a-z, numbers 0-9, and characters '-' '/' '?' '%' '#' and '&' are allowed. URLs must be started with the character '/', but cannot be '/' alone.