Listener
Provides an Application Load Balancer Listener resource. For information about slb and how to use it, see What is Server Load Balancer. For information about listener and how to use it, to see the following:
NOTE: Available since v1.0.0.
Example Usage
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.slb.ApplicationLoadBalancer;
import com.pulumi.alicloud.slb.ApplicationLoadBalancerArgs;
import com.pulumi.alicloud.slb.Acl;
import com.pulumi.alicloud.slb.AclArgs;
import com.pulumi.alicloud.slb.Listener;
import com.pulumi.alicloud.slb.ListenerArgs;
import com.pulumi.alicloud.slb.inputs.ListenerXForwardedForArgs;
import com.pulumi.alicloud.slb.AclEntryAttachment;
import com.pulumi.alicloud.slb.AclEntryAttachmentArgs;
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 slbListenerName = config.get("slbListenerName").orElse("forSlbListener");
var listenerApplicationLoadBalancer = new ApplicationLoadBalancer("listenerApplicationLoadBalancer", ApplicationLoadBalancerArgs.builder()
.loadBalancerName("tf-exampleSlbListenerHttp")
.internetChargeType("PayByTraffic")
.addressType("internet")
.instanceChargeType("PayByCLCU")
.build());
var listenerAcl = new Acl("listenerAcl", AclArgs.builder()
.ipVersion("ipv4")
.build());
var listenerListener = new Listener("listenerListener", ListenerArgs.builder()
.loadBalancerId(listenerApplicationLoadBalancer.id())
.backendPort(80)
.frontendPort(80)
.protocol("http")
.bandwidth(10)
.stickySession("on")
.stickySessionType("insert")
.cookieTimeout(86400)
.cookie("tfslblistenercookie")
.healthCheck("on")
.healthCheckDomain("ali.com")
.healthCheckUri("/cons")
.healthCheckConnectPort(20)
.healthyThreshold(8)
.unhealthyThreshold(8)
.healthCheckTimeout(8)
.healthCheckInterval(5)
.healthCheckHttpCode("http_2xx,http_3xx")
.xForwardedFor(ListenerXForwardedForArgs.builder()
.retriveSlbIp(true)
.retriveSlbId(true)
.build())
.aclStatus("on")
.aclType("white")
.aclId(listenerAcl.id())
.requestTimeout(80)
.idleTimeout(30)
.build());
var first = new AclEntryAttachment("first", AclEntryAttachmentArgs.builder()
.aclId(listenerAcl.id())
.entry("10.10.10.0/24")
.comment("first")
.build());
var second = new AclEntryAttachment("second", AclEntryAttachmentArgs.builder()
.aclId(listenerAcl.id())
.entry("168.10.10.0/24")
.comment("second")
.build());
}
}
Listener fields and protocol mapping
load balance support 4 protocol to listen on, they are http
,https
,tcp
,udp
, the every listener support which portocal following: listener parameter | support protocol | value range | ------------- | ------------- | ------------- | backend_port | http & https & tcp & udp | 1-65535 | frontend_port | http & https & tcp & udp | 1-65535 | protocol | http & https & tcp & udp | bandwidth | http & https & tcp & udp | -1 / 1-1000 | scheduler | http & https & tcp & udp | wrr, rr, wlc, tch, qch | sticky_session | http & https | on or off | sticky_session_type | http & https | insert or server | cookie_timeout | http & https | 1-86400 | cookie | http & https | | persistence_timeout | tcp & udp | 0-3600 | health_check | http & https | on or off | health_check_type | tcp | tcp or http | health_check_domain | http & https & tcp | health_check_method | http & https & tcp | health_check_uri | http & https & tcp | | health_check_connect_port | http & https & tcp & udp | 1-65535 or -520 | healthy_threshold | http & https & tcp & udp | 1-10 | unhealthy_threshold | http & https & tcp & udp | 1-10 | health_check_timeout | http & https & tcp & udp | 1-300 | health_check_interval | http & https & tcp & udp | 1-50 | health_check_http_code | http & https & tcp | http_2xx,http_3xx,http_4xx,http_5xx | server_certificate_id | https | | gzip | http & https | true or false | x_forwarded_for | http & https | | acl_status | http & https & tcp & udp | on or off | acl_type | http & https & tcp & udp | white or black | acl_id | http & https & tcp & udp | the id of resource alicloud_slb_acl| established_timeout | tcp | 10-900| idle_timeout |http & https | 1-60 | request_timeout |http & https | 1-180 | enable_http2 |https | on or off | tls_cipher_policy |https | tls_cipher_policy_1_0, tls_cipher_policy_1_1, tls_cipher_policy_1_2, tls_cipher_policy_1_2_strict | server_group_id | http & https & tcp & udp | the id of resource alicloud.slb.ServerGroup | The listener mapping supports the following:
Import
Load balancer listener can be imported using the id, e.g.
$ pulumi import alicloud:slb/listener:Listener example "lb-abc123456:tcp:22"
Properties
Mode for handling the acl specified by acl_id. If acl_status
is "on", it is mandatory. Otherwise, it will be ignored. Valid values are white
and black
. white
means the Listener can only be accessed by client ip belongs to the acl; black
means the Listener can not be accessed by client ip belongs to the acl.
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 $.
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.
HealthCheckMethod used for health check.Valid values: "head", "get" http
and https
support regions ap-northeast-1, ap-southeast-1, ap-southeast-2, ap-southeast-3, us-east-1, us-west-1, eu-central-1, ap-south-1, me-east-1, cn-huhehaote, cn-zhangjiakou, ap-southeast-5, cn-shenzhen, cn-hongkong, cn-qingdao, cn-chengdu, eu-west-1, cn-hangzhou", cn-beijing, cn-shanghai.This function does not support the TCP protocol .
The number of health checks that an unhealthy backend server must consecutively pass before it can be declared healthy. In this case, the health check state is changed from fail to success. It is required when health_check
is on. Valid value range: 2-10 in seconds. Default to 3. NOTE: This parameter takes effect only if the health_check
parameter is set to on
.
Scheduling algorithm, Valid values: wrr
, rr
, wlc
, sch
, tcp
, qch
. Default to wrr
. Only when protocol
is tcp
or udp
, scheduler
can be set to sch
. Only when instance is guaranteed-performance instance and protocol
is tcp
or udp
, scheduler
can be set to tch
. Only when instance is guaranteed-performance instance and protocol
is udp
, scheduler
can be set to qch
.
The number of health checks that a healthy backend server must consecutively fail before it can be declared unhealthy. In this case, the health check state is changed from success to fail. It is required when health_check
is on. Valid value range: 2-10 in seconds. Default to 3. NOTE: This parameter takes effect only if the health_check
parameter is set to on
.