Listener

Provides a NLB Listener resource. For information about NLB Listener and how to use it, see What is Listener.

NOTE: Available in v1.191.0+.

Example Usage

Basic Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.vpc.VpcFunctions;
import com.pulumi.alicloud.vpc.inputs.GetNetworksArgs;
import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
import com.pulumi.alicloud.nlb.ServerGroup;
import com.pulumi.alicloud.nlb.ServerGroupArgs;
import com.pulumi.alicloud.nlb.inputs.ServerGroupHealthCheckArgs;
import com.pulumi.alicloud.nlb.NlbFunctions;
import com.pulumi.alicloud.nlb.inputs.GetZonesArgs;
import com.pulumi.alicloud.vpc.inputs.GetSwitchesArgs;
import com.pulumi.alicloud.nlb.LoadBalancer;
import com.pulumi.alicloud.nlb.LoadBalancerArgs;
import com.pulumi.alicloud.nlb.inputs.LoadBalancerZoneMappingArgs;
import com.pulumi.alicloud.nlb.Listener;
import com.pulumi.alicloud.nlb.ListenerArgs;
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 defaultNetworks = VpcFunctions.getNetworks(GetNetworksArgs.builder()
.nameRegex("default-NODELETING")
.build());
final var defaultResourceGroups = ResourcemanagerFunctions.getResourceGroups();
var defaultServerGroup = new ServerGroup("defaultServerGroup", ServerGroupArgs.builder()
.resourceGroupId(defaultResourceGroups.applyValue(getResourceGroupsResult -> getResourceGroupsResult.ids()[0]))
.serverGroupName(var_.name())
.serverGroupType("Instance")
.vpcId(defaultNetworks.applyValue(getNetworksResult -> getNetworksResult.ids()[0]))
.scheduler("Wrr")
.protocol("TCP")
.healthCheck(ServerGroupHealthCheckArgs.builder()
.healthCheckUrl("/test/index.html")
.healthCheckDomain("tf-testAcc.com")
.healthCheckEnabled(true)
.healthCheckType("TCP")
.healthCheckConnectPort(0)
.healthyThreshold(2)
.unhealthyThreshold(2)
.healthCheckConnectTimeout(5)
.healthCheckInterval(10)
.httpCheckMethod("GET")
.healthCheckHttpCodes(
"http_2xx",
"http_3xx",
"http_4xx")
.build())
.connectionDrain(true)
.connectionDrainTimeout(60)
.preserveClientIpEnabled(true)
.tags(Map.of("Created", "TF"))
.addressIpVersion("Ipv4")
.build());
final var defaultZones = NlbFunctions.getZones();
final var default1 = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
.vpcId(defaultNetworks.applyValue(getNetworksResult -> getNetworksResult.ids()[0]))
.zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.build());
final var default2 = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
.vpcId(defaultNetworks.applyValue(getNetworksResult -> getNetworksResult.ids()[0]))
.zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[1].id()))
.build());
final var zoneId1 = defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id());
final var vswitchId1 = default1.applyValue(getSwitchesResult -> getSwitchesResult.ids()[0]);
final var zoneId2 = defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[1].id());
final var vswitchId2 = default2.applyValue(getSwitchesResult -> getSwitchesResult.ids()[0]);
var defaultLoadBalancer = new LoadBalancer("defaultLoadBalancer", LoadBalancerArgs.builder()
.loadBalancerName(var_.name())
.resourceGroupId(defaultResourceGroups.applyValue(getResourceGroupsResult -> getResourceGroupsResult.ids()[0]))
.loadBalancerType("Network")
.addressType("Internet")
.addressIpVersion("Ipv4")
.tags(Map.ofEntries(
Map.entry("Created", "tfTestAcc0"),
Map.entry("For", "Tftestacc 0")
))
.vpcId(defaultNetworks.applyValue(getNetworksResult -> getNetworksResult.ids()[0]))
.zoneMappings(
LoadBalancerZoneMappingArgs.builder()
.vswitchId(vswitchId1)
.zoneId(zoneId1)
.build(),
LoadBalancerZoneMappingArgs.builder()
.vswitchId(vswitchId2)
.zoneId(zoneId2)
.build())
.build());
var defaultListener = new Listener("defaultListener", ListenerArgs.builder()
.listenerProtocol("TCP")
.listenerPort("80")
.listenerDescription(var_.name())
.loadBalancerId(defaultLoadBalancer.id())
.serverGroupId(defaultServerGroup.id())
.idleTimeout("900")
.proxyProtocolEnabled("true")
.secSensorEnabled("true")
.cps("10000")
.mss("0")
.build());
}
}

Import

NLB Listener can be imported using the id, e.g.

$ pulumi import alicloud:nlb/listener:Listener example <id>

Properties

Link copied to clipboard
val alpnEnabled: Output<Boolean>

Specifies whether to enable Application-Layer Protocol Negotiation (ALPN).

Link copied to clipboard
val alpnPolicy: Output<String>?

The ALPN policy.

Link copied to clipboard

The list of certificate authority (CA) certificates. This parameter takes effect only for listeners that use SSL over TCP. Note: Only one CA certificate is supported.

Link copied to clipboard
val caEnabled: Output<Boolean>

Specifies whether to enable mutual authentication.

Link copied to clipboard
val certificateIds: Output<List<String>>?

The list of server certificates. This parameter takes effect only for listeners that use SSL over TCP. Note: Only one server certificate is supported.

Link copied to clipboard
val cps: Output<Int>?

The maximum number of connections that can be created per second on the NLB instance. Valid values: 0 to 1000000. 0 specifies that the number of connections is unlimited.

Link copied to clipboard
val endPort: Output<Int>?

Full port listening end port. Valid values: 0 ~ 65535. The value of the end port is less than the start port.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val idleTimeout: Output<Int>

The timeout period of an idle connection. Unit: seconds. Valid values: 1 to 900. Default value: 900.

Link copied to clipboard

Custom listener name. The length is limited to 2 to 256 characters, supports Chinese and English letters, and can include numbers, commas (,), half-width periods (.), half-width semicolons (;), forward slashes (/), at(@), underscores (_), and dashes (-).

Link copied to clipboard
val listenerPort: Output<Int>

Listening port. Valid values: 0 ~ 65535. 0: indicates that full port listening is used. When set to 0, you must configure StartPort and EndPort.

Link copied to clipboard

The listening protocol. Valid values: TCP, UDP, or TCPSSL.

Link copied to clipboard
val loadBalancerId: Output<String>

The ID of the network-based server load balancer instance.

Link copied to clipboard
val mss: Output<Int>?

The maximum size of a TCP segment. Unit: bytes. Valid values: 0 to 1500. 0 specifies that the maximum segment size remains unchanged. Note: This parameter is supported only by listeners that use SSL over TCP.

Link copied to clipboard

Specifies whether to use the Proxy protocol to pass client IP addresses to backend servers.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Specifies whether to enable fine-grained monitoring.

Link copied to clipboard

The ID of the security policy. System security policies and custom security policies are supported. Valid values: tls_cipher_policy_1_0 (default), tls_cipher_policy_1_1, tls_cipher_policy_1_2, tls_cipher_policy_1_2_strict, and tls_cipher_policy_1_2_strict_with_1_3.

Link copied to clipboard
val serverGroupId: Output<String>

The ID of the server group.

Link copied to clipboard
val startPort: Output<Int>?

Full Port listens to the starting port. Valid values: 0 ~ 65535.

Link copied to clipboard
val status: Output<String>

The status of the resource. Valid values: Running, Stopped.

Link copied to clipboard
val urn: Output<String>