Show / Hide Table of Contents

Class 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:

  • Configure a HTTP Listener.
  • Configure a HTTPS Listener.
  • Configure a TCP Listener.
  • Configure a UDP Listener.

Example Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
public MyStack()
{
    var config = new Config();
    var name = config.Get("name") ?? "testcreatehttplistener";
    var ipVersion = config.Get("ipVersion") ?? "ipv4";
    var defaultLoadBalancer = new AliCloud.Slb.LoadBalancer("defaultLoadBalancer", new AliCloud.Slb.LoadBalancerArgs
    {
        Internet = true,
        InternetChargeType = "PayByTraffic",
    });
    var defaultAcl = new AliCloud.Slb.Acl("defaultAcl", new AliCloud.Slb.AclArgs
    {
        EntryLists = 
        {
            new AliCloud.Slb.Inputs.AclEntryListArgs
            {
                Comment = "first",
                Entry = "10.10.10.0/24",
            },
            new AliCloud.Slb.Inputs.AclEntryListArgs
            {
                Comment = "second",
                Entry = "168.10.10.0/24",
            },
        },
        IpVersion = ipVersion,
    });
    var defaultListener = new AliCloud.Slb.Listener("defaultListener", new AliCloud.Slb.ListenerArgs
    {
        AclId = defaultAcl.Id,
        AclStatus = "on",
        AclType = "white",
        BackendPort = 80,
        Bandwidth = 10,
        Cookie = "testslblistenercookie",
        CookieTimeout = 86400,
        FrontendPort = 80,
        HealthCheck = "on",
        HealthCheckConnectPort = 20,
        HealthCheckDomain = "ali.com",
        HealthCheckHttpCode = "http_2xx,http_3xx",
        HealthCheckInterval = 5,
        HealthCheckTimeout = 8,
        HealthCheckUri = "/cons",
        HealthyThreshold = 8,
        IdleTimeout = 30,
        LoadBalancerId = defaultLoadBalancer.Id,
        Protocol = "http",
        RequestTimeout = 80,
        StickySession = "on",
        StickySessionType = "insert",
        UnhealthyThreshold = 8,
        XForwardedFor = new AliCloud.Slb.Inputs.ListenerXForwardedForArgs
        {
            RetriveSlbId = true,
            RetriveSlbIp = true,
        },
    });
}

}

Listener fields and protocol mapping

load balance support 4 protocal 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 or wlc
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:

Inheritance
System.Object
Resource
CustomResource
Listener
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.AliCloud.Slb
Assembly: Pulumi.AliCloud.dll
Syntax
public class Listener : CustomResource

Constructors

View Source

Listener(String, ListenerArgs, CustomResourceOptions)

Create a Listener resource with the given unique name, arguments, and options.

Declaration
public Listener(string name, ListenerArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

ListenerArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

AclId

the id of access control list to be apply on the listener, is the id of resource alicloud_slb_acl. If acl_status is "on", it is mandatory. Otherwise, it will be ignored.

Declaration
public Output<string> AclId { get; }
Property Value
Type Description
Output<System.String>
View Source

AclStatus

Whether to enable "acl(access control list)", the acl is specified by acl_id. Valid values are on and off. Default to off.

Declaration
public Output<string> AclStatus { get; }
Property Value
Type Description
Output<System.String>
View Source

AclType

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.

Declaration
public Output<string> AclType { get; }
Property Value
Type Description
Output<System.String>
View Source

BackendPort

Port used by the Server Load Balancer instance backend. Valid value range: [1-65535].

Declaration
public Output<int?> BackendPort { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

Bandwidth

Bandwidth peak of Listener. For the public network instance charged per traffic consumed, the Bandwidth on Listener can be set to -1, indicating the bandwidth peak is unlimited. Valid values are [-1, 1-1000] in Mbps.

Declaration
public Output<int?> Bandwidth { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

Cookie

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 $.

Declaration
public Output<string> Cookie { get; }
Property Value
Type Description
Output<System.String>
View Source

CookieTimeout

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.

Declaration
public Output<int?> CookieTimeout { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

DeleteProtectionValidation

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

Declaration
public Output<bool?> DeleteProtectionValidation { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

Description

The description of slb listener. This description can have a string of 1 to 80 characters. Default value: null.

Declaration
public Output<string> Description { get; }
Property Value
Type Description
Output<System.String>
View Source

EnableHttp2

Whether to enable https listener support http2 or not. Valid values are on and off. Default to on.

Declaration
public Output<string> EnableHttp2 { get; }
Property Value
Type Description
Output<System.String>
View Source

EstablishedTimeout

Timeout of tcp listener established connection idle timeout. Valid value range: [10-900] in seconds. Default to 900.

Declaration
public Output<int?> EstablishedTimeout { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

ForwardPort

The port that http redirect to https.

Declaration
public Output<int?> ForwardPort { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

FrontendPort

Port used by the Server Load Balancer instance frontend. Valid value range: [1-65535].

Declaration
public Output<int> FrontendPort { get; }
Property Value
Type Description
Output<System.Int32>
View Source

Gzip

Whether to enable "Gzip Compression". If enabled, files of specific file types will be compressed, otherwise, no files will be compressed. Default to true. Available in v1.13.0+.

Declaration
public Output<bool?> Gzip { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

HealthCheck

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.

Declaration
public Output<string> HealthCheck { get; }
Property Value
Type Description
Output<System.String>
View Source

HealthCheckConnectPort

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

Declaration
public Output<int> HealthCheckConnectPort { get; }
Property Value
Type Description
Output<System.Int32>
View Source

HealthCheckDomain

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.

Declaration
public Output<string> HealthCheckDomain { get; }
Property Value
Type Description
Output<System.String>
View Source

HealthCheckHttpCode

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.

Declaration
public Output<string> HealthCheckHttpCode { get; }
Property Value
Type Description
Output<System.String>
View Source

HealthCheckInterval

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

Declaration
public Output<int?> HealthCheckInterval { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

HealthCheckMethod

The method of health check. Valid values: ["head", "get"].

Declaration
public Output<string> HealthCheckMethod { get; }
Property Value
Type Description
Output<System.String>
View Source

HealthCheckTimeout

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.

Declaration
public Output<int?> HealthCheckTimeout { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

HealthCheckType

Type of health check. Valid values are: tcp and http. Default to tcp . TCP supports TCP and HTTP health check mode, you can select the particular mode depending on your application.

Declaration
public Output<string> HealthCheckType { get; }
Property Value
Type Description
Output<System.String>
View Source

HealthCheckUri

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.

Declaration
public Output<string> HealthCheckUri { get; }
Property Value
Type Description
Output<System.String>
View Source

HealthyThreshold

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.

Declaration
public Output<int?> HealthyThreshold { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

IdleTimeout

Timeout of http or https listener established connection idle timeout. Valid value range: [1-60] in seconds. Default to 15.

Declaration
public Output<int?> IdleTimeout { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

InstancePort

Declaration
public Output<int?> InstancePort { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

LbPort

Declaration
public Output<int?> LbPort { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

LbProtocol

Declaration
public Output<string> LbProtocol { get; }
Property Value
Type Description
Output<System.String>
View Source

ListenerForward

Whether to enable http redirect to https, Valid values are on and off. Default to off.

Declaration
public Output<string> ListenerForward { get; }
Property Value
Type Description
Output<System.String>
View Source

LoadBalancerId

The Load Balancer ID which is used to launch a new listener.

Declaration
public Output<string> LoadBalancerId { get; }
Property Value
Type Description
Output<System.String>
View Source

MasterSlaveServerGroupId

Declaration
public Output<string> MasterSlaveServerGroupId { get; }
Property Value
Type Description
Output<System.String>
View Source

PersistenceTimeout

Timeout of connection persistence. Valid value range: [0-3600] in seconds. Default to 0 and means closing it.

Declaration
public Output<int?> PersistenceTimeout { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

Protocol

The protocol to listen on. Valid values are [http, https, tcp, udp].

Declaration
public Output<string> Protocol { get; }
Property Value
Type Description
Output<System.String>
View Source

RequestTimeout

Timeout of http or https listener request (which does not get response from backend) timeout. Valid value range: [1-180] in seconds. Default to 60.

Declaration
public Output<int?> RequestTimeout { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

Scheduler

Scheduling algorithm, Valid values are wrr, rr and wlc. Default to "wrr".

Declaration
public Output<string> Scheduler { get; }
Property Value
Type Description
Output<System.String>
View Source

ServerCertificateId

SLB Server certificate ID. It is required when protocol is https.

Declaration
public Output<string> ServerCertificateId { get; }
Property Value
Type Description
Output<System.String>
View Source

ServerGroupId

the id of server group to be apply on the listener, is the id of resource alicloud.slb.ServerGroup.

Declaration
public Output<string> ServerGroupId { get; }
Property Value
Type Description
Output<System.String>
View Source

SslCertificateId

It has been deprecated from 1.59.0 and using server_certificate_id instead.

Declaration
public Output<string> SslCertificateId { get; }
Property Value
Type Description
Output<System.String>
View Source

StickySession

Whether to enable session persistence, Valid values are on and off. Default to off.

Declaration
public Output<string> StickySession { get; }
Property Value
Type Description
Output<System.String>
View Source

StickySessionType

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.

Declaration
public Output<string> StickySessionType { get; }
Property Value
Type Description
Output<System.String>
View Source

TlsCipherPolicy

Https listener TLS cipher policy. Valid values are tls_cipher_policy_1_0, tls_cipher_policy_1_1, tls_cipher_policy_1_2, tls_cipher_policy_1_2_strict. Default to tls_cipher_policy_1_0. Currently the tls_cipher_policy can not be updated when load balancer instance is "Shared-Performance".

Declaration
public Output<string> TlsCipherPolicy { get; }
Property Value
Type Description
Output<System.String>
View Source

UnhealthyThreshold

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.

Declaration
public Output<int?> UnhealthyThreshold { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

XForwardedFor

Whether to set additional HTTP Header field "X-Forwarded-For" (documented below). Available in v1.13.0+.

Declaration
public Output<ListenerXForwardedFor> XForwardedFor { get; }
Property Value
Type Description
Output<ListenerXForwardedFor>

Methods

View Source

Get(String, Input<String>, ListenerState, CustomResourceOptions)

Get an existing Listener resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static Listener Get(string name, Input<string> id, ListenerState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

ListenerState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
Listener
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.